| Change 1 or more spaces into a single space.
| :%s/ */ /g
|
| Remove all spaces from the end of the line.
| :%s/ *$//
|
| Insert a space at the beginning of every line.
| :%s/^/ /
|
| Remove all numbers at the beginning of a line.
| :%s/^[0-9][0-9]* //
|
| Change all occurences of bag, beg, big, and bog, to bug.
| :%s/b[aeio]g/bug/g
|
| Change all occurences of tag, tog, and tug to hat, hot, and hug respectively.
| :%s/t\([aou]\)g/h\1t/g
|
| Removes all empty lines
| awk '$0 !~ /^$/' price.txt
|
| Print the third field of all lines whose second field begins with 'J' or 'T'
| awk '$2 ~ /^[JT]/ {print $3}' price.txt
|
| All lines whose second field does not contain 'Misc' or 'misc' print the sum of columns 3 and 4 (assumed to be numbers).
| awk '$2 !~ /[Mm]isc/ {print $3 + $4}' price.txt
|
| All lines where field 3 is not a number. The number must be of the form: d.d or d. where d is any number of digits from 0 to 9.
| awk '$3 !~ /^[0-9]+\.[0-9]*$/ {print $0}' price.txt
|
| The entire line if the second field contains 'John' or 'Fred'
| Fred/ {print $0}' price.txt
|