Archive for July, 2011

IPv4 File Parser Linux Command Line

2011-07-18 Leave a comment

This single line of code grabs any IP address from a list of files and sorts them and removes all duplicates then puts them in a file with and extension of .ip

for file in *; do cat $file | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 | uniq -u >> $file.ip; done
Categories: Linux