An open API service indexing awesome lists of open source software.

https://github.com/loglux-lab/ip-extractor

ip-extractor.sh uses nano to extract IP addresses. Results are stored in 'hosts', with duplicates removed. Ideal for sifting through logs and data-rich files.
https://github.com/loglux-lab/ip-extractor

bash extract-data linux-shell nano regex regular-expression

Last synced: 1 day ago
JSON representation

ip-extractor.sh uses nano to extract IP addresses. Results are stored in 'hosts', with duplicates removed. Ideal for sifting through logs and data-rich files.

Awesome Lists containing this project

README

          

# IP-Extractor

**ip-extractor.sh** is a Bash script designed to extract IP addresses from any text input via the `nano` editor. It processes the input, saves clean IP lists into several formats, and provides immediate feedback in the console.

---

## 📦 Prerequisites

- Bash-compatible environment (Linux, macOS, WSL, etc.)
- `nano` editor installed
- Standard Unix tools: `grep`, `sort`, `tr`, `cat`, `rm`, `sed`, etc.

---

## 🚀 Usage

1. Run the script:

```bash
./ip-extractor.sh
```

2. On first run, a file called `load` will be opened in `nano`. Paste your raw text (e.g., log files, traceroutes, firewall logs).

3. Save and exit (`Ctrl + O`, `Enter`, `Ctrl + X`).

4. The script will:
- Extract all non-localhost IPv4 addresses
- Save them to a file called `hosts`
- Remove duplicates
- Create two additional files:
- `hostcom`: IPs in a comma-separated format
- `chost`: IPs in a space-separated format
- Display the final list of IPs in console
- Inform how many IPs were found

---

## 📁 Output Files

| File | Description |
|-----------|---------------------------------------------|
| `hosts` | Unique extracted IP addresses, one per line |
| `hostcom` | Same IPs as in `hosts`, comma-separated |
| `chost` | Same IPs as in `hosts`, space-separated |
| `load` | Temporary input file (deleted after run) |
| `loadlast`| Copy of last processed input |

---

## 🛠 Features

- Clean parsing: skips `127.*.*.*` and non-IP lines
- Visual feedback (`▓`, `Done!`) during processing
- Duplicate removal via `sort -u`
- Auto-relaunches itself if `load` file is empty or missing
- Multi-format output: plain, comma, and space-separated

---

## 🔁 Notes

- The script only works with **IPv4** addresses.
- Edit the regex in `grep` if you want to support other formats or behaviours.
- You can comment or customise the `JobFin` messages for quieter output.

---

## 🙋 Contributing

This is a lightweight utility meant for quick daily tasks. Feel free to submit enhancements, especially:
- IPv6 support
- GUI-based input (e.g. with `zenity`)
- Output to JSON or CSV