Skip to content

Instantly share code, notes, and snippets.

@clifferson
Created July 18, 2012 20:22
Show Gist options
  • Save clifferson/3138612 to your computer and use it in GitHub Desktop.
Save clifferson/3138612 to your computer and use it in GitHub Desktop.
Make awk do some grep
If you want to search field one for (part of) a string:
awk '$1 ~ /search string/ { print $2 }' example.txt
If the search string should match anywhere in the line (all fields):
awk '/search string/ { print $2 }' example.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment