history | awk '{a[$2]++}END{for(i in a)print a[i] "" i} }'
awk 'NR==FNR{a[$2]=$1;next} {$1=a[$1]}1' mapfile datafile
# prints lines that are both in file1 and file2 (intersection)
awk 'NR==FNR{a[$0];next} $0 in a' file1 file2
# replace each number with its difference from the maximum
awk 'NR==FNR{if($0>max) max=$0;next} {$0=max-$0}1' file file
# prints lines from /beginpat/ to /endpat/, not inclusive
awk '/beginpat/,/endpat/{if (!/beginpat/&&!/endpat/)print}'
# prints lines from /beginpat/ to /endpat/, excluding /endpat/
awk '/endpat/{p=0} /beginpat/{p=1} p'
http://www.tomschaefer.org/web/wordpress/?p=1692
http://backreference.org/page/3/
http://www.catonmat.net/blog/ten-awk-tips-tricks-and-pitfalls/
No comments:
Post a Comment