AWK tricks and tips

  • remove duplicate lines without sorting (will keep first instance)
    awk '!a[$0]++' file

  • filtering – if the 5th column is 0 then skip it and print the rest
    awk '{ if ($5 == 0) next; print }' file

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.