Skip to content

Instantly share code, notes, and snippets.

@ctokheim
Last active April 18, 2017 21:55
Show Gist options
  • Save ctokheim/5338940 to your computer and use it in GitHub Desktop.
Save ctokheim/5338940 to your computer and use it in GitHub Desktop.
Awk: tricks
# sum a column
cat your_file.txt | awk '{sum+=$5} END {print sum}'
# use specific delimiters
cat your_file.txt | awk -F" " '{OFS="\t";}{print $1, $2-1, $3-1, $5}'
# grab certain lines in a file
cat your_file.txt | awk 'FNR==10'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment