vimwiki

Awk

Text processing tool. Manipulate and analyse text files in a line by line manner. Useful for extracting fields, filtering data, performing calculations.

Basics

awk 'pattern { action }' input_file

Print for each lines the given field. By default, fields are separated by spaces. The field to print is specified with $n.

awk '{ print $2, $3 }' input_file

The field separator can be specified with the -F flag.

awk -F ',' '{ print $5 }' input_file

Built in variable

Condition

awk '{ if ($1 > 10) print $0 }' input_file