Skip to content

Instantly share code, notes, and snippets.

@charrismatic
Created May 19, 2020 01:13
Show Gist options
  • Save charrismatic/80de258bac9fb6c701673f3d0bfe7025 to your computer and use it in GitHub Desktop.
Save charrismatic/80de258bac9fb6c701673f3d0bfe7025 to your computer and use it in GitHub Desktop.
ServerOps IP Tools
#!/bin/bash
# FILTERS IP ADDRESSES FROM LOG
# USAGE: find /var/log -type f -exec cat {} \; | get-ips.sh
grep \
--only-matching \
--color=never \
-E "[0-9]{1,3}\.[1-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" \
| sort --version-sort \
| uniq -c \
| sort -r \
--version-sort \
--ignore-leading-blanks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment