Awk Cheatsheet
Links Awk tutorial Pattern matching (grep) # Should return one line per file ls -a | awk '//' # Should print files starting with a dot ls -a | awk '/^\./' Counting (wc) ls | awk '{i++} END {print i}' # Should return number of files Delete all svn-files with an exclamation mark in svn status svn status | awk '/^!/{print $2}' | xargs svn delete --force Find only the first match and print it echo data | awk "/$pattern/{print;exit}" Ignore the first line echo data | awk 'NR>1' Ignore duplicate lines echo data | awk '!seen[$0]++' Insert a line after a pattern echo data | awk '/match/{print;print "Inserted line";next}1' Insert a line before a pattern echo data | awk '/match/{print "Inserted line"}1' Print second column # head -n 1 | cut -d ' ' -f2 awk '{print $2; exit}'