Created
October 4, 2022 20:17
-
-
Save ingmarioalberto/f9ec4c26e89785c3829b34f075c71d84 to your computer and use it in GitHub Desktop.
Filter out homolog IP address, -i = invert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOMO="\([0-9]\.\|[1]\{,1\}[0-9]\{2\}\.\|2[0-4][0-9]\.\|25[0-5]\.\)\{3\}\([0-9]\|[1]\{,1\}[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)" | |
LAN10="10\(\.[0-9]\|\.[1]\{,1\}[0-9]\{2\}\|\.2[0-4][0-9]\|\.25[0-5]\)\{3\}" | |
LAN172="172\.\(1[6-9]\|2[0-9]\|3[01]\)\.\([0-9]\.\|[1]\{,1\}[0-9]\{2\}\.\|2[0-4][0-9]\.\|25[0-5]\.\)\([0-9]\|[1]\{,1\}[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)" | |
LAN192168="192.168\(\.[0-9]\|\.[1]\{,1\}[0-9]\{2\}\|\.2[0-4][0-9]\|\.25[0-5]\)\{2\}" | |
LANSELF="127.0.0.1" | |
LANWEIRD="169.254.169.254" | |
case ${1} in | |
"-i") | |
OUT=$(cat - | grep -e ${LANSELF} -e ${LAN10} -e ${LAN172} -e ${LAN192168} | grep -v ${LANWEIRD}) | |
;; | |
*) | |
OUT=$(cat - | grep -e ${HOMO}) | |
OUT=$(echo "${OUT}" | grep -v -e ${LANSELF}) | |
OUT=$(echo "${OUT}" | grep -v -e ${LAN10}) | |
OUT=$(echo "${OUT}" | grep -v -e ${LAN172}) | |
OUT=$(echo "${OUT}" | grep -v -e ${LAN192168}) | |
OUT=$(echo "${OUT}" | grep -v -e ${LANWEIRD}) | |
;; | |
esac | |
echo "${OUT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment