Wednesday, February 1, 2012

awk filtering and soring by parameter

file:
aaa \t bbb \t 3
bbb \t ssd \t 4

Exclude rows with $3 (3rd parameter) <=1 and sort it by 3rd column:

awk -F"\t" '$3>1 {print}' test | sort -n -r -t'     ' -k3> test_filter_gt1

Get number of different words in the 2nd column:
awk -F"      " '{print $2}' test_filter_gt1 | sort  | uniq -c -i | wc -l

No comments:

Post a Comment