awk Statement

From GM-RKB
Jump to navigation Jump to search

A awk Statement is a statement based on the awk Tool.

  • Example(s):
    • awk -F'[. ]' '{ if (a[$2]++ == 0) print }', which removes the duplicates depending on the 2nd column.
    • awk -F"[. ]" '!a[$2]++', which removes the duplicates depending on the 2nd column.
    • awk -F"|" '{print $2"|"$1}' inputFile, which swaps the first two pipe-separated columns.
    • awk '{print FILENAME"_"$0'} *txt  ;, which prepends the corresponding filename to each line.
  • Counter-Example(s):
  • See: Unix Tool.