Print the first field of each line
Type here
awk '{print $1}' corpus.txt
Print specific field using a delimiter
Type here
awk -F: '{print $1}' /etc/passwd
Print specific fields from a TSV file
Type here
awk -F'\t' '{print $1, $3}' data.tsv
Count total words across all lines with awk
Type here
awk '{total += NF} END {print total}' corpus.txt
Print lines longer than N characters
Type here
awk 'length($0) > 100' corpus.txt
Print lines with more than N words
Type here
awk 'NF > 10' corpus.txt
Add line numbers to a corpus file
Type here
awk '{print NR"\t"$0}' corpus.txt > numbered.txt