Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # File Spacing
- # double space a file
- awk '1;{print ""}'
- awk 'BEGIN{ORS="\n\n"};1'
- # triple space
- awk '1;{print "\n"}'
- # precede each line by its line number FOR ALL FILES TOGETHER, with tab.
- awk '{print NR "\t" $0}' files*
- # count lines (emulates "wc -l")
- awk 'END{print NR}'
- # print every line after replacing each field with its absolute value
- awk '{for (i=1; i<=NF; i++) if ($i < 0) $i = -$i; print }'
- awk '{for (i=1; i<=NF; i++) $i = ($i < 0) ? -$i : $i; print }'
- # print the total number of lines that contain "Darn"
- awk '/Darn/{n++}; END {print n+0}' file
- # print the last field of the last line
- awk '{ field = $NF }; END{ print field }'
- # print every line with more than 4 fields
- awk 'NF > 4'
- # delete leading whitespace (spaces, tabs) from front of each line
- # aligns all text flush left
- awk '{sub(/^[ \t]+/, "")};1'
- # delete trailing whitespace (spaces, tabs) from end of each line
- awk '{sub(/[ \t]+$/, "")};1'
- # grep for AAA and BBB and CCC (in any order on the same line)
- awk '/AAA/ && /BBB/ && /CCC/'
- # grep for AAA and BBB and CCC (in that order)
- awk '/AAA.*BBB.*CCC/'
Advertisement
Add Comment
Please, Sign In to add comment