Tuesday, August 4, 2009

Using Grep to return only the match, getting unique/distinct results, and sorting

Display only the matches (in this case, occurrences of 6 numbers in a row)

grep -o "[0-9]\{6\}" test.txt

Removing repeated results, and sorting

grep -o "[0-9]\{6\}" test.txt | uniq | sort

Woo.