> For the complete documentation index, see [llms.txt](https://wiki.smhuda.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.smhuda.com/misc/scripts/grep-ip-addresses.md).

# Grep IP Addresses

### A grep command to get all IP addresses contained in a text file:

```
$ grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' IPs-To-Grep.txt > Grepped-ips.txt
```

### Grep IP Address with their CIDRs from a text file:

```
egrep -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+/[0-9]+' scope.txt > final-scope.txt
```
