Again on IRC, somebody asked how to remove duplicates from a file, but keeping only the last occurrence of each item. The classic awk idiom awk '!a[$0]++' prints only the first instance of every line. So if the input is, for example foo bar baz foo xxx yyy bar the "normal" output (ie using the […]
Archive of posts tagged text processing
“In-place” editing of files
Temporary files don't bite, so just use them.
Joining files with awk
Join lines from files based on keys
Smart ranges in awk, part two
Another variation on the theme