2009年12月3日星期四

zgrep/grep pipeline

Table:

Roosevelt Tommy 38 54579 555-1212

Nixon Edward 19 37583 246-3457

Roosevelt Freddie 47 11745 674-6972

Lincoln Albert 26 26452 916-5763

If you wanted to find all the Roosevelts and sort them by zip code, you could do it like this:

grep Roosevelt people.txt > grep.out
sort +3 grep.out
rm grep.out


Alternately,
grep Roosevelt people.txt | sort +3 > sort-results