Skip to content

Instantly share code, notes, and snippets.

@henkin
Created August 15, 2020 07:50
Show Gist options
  • Save henkin/aee1642825367ae8e745fdd05e931911 to your computer and use it in GitHub Desktop.
Save henkin/aee1642825367ae8e745fdd05e931911 to your computer and use it in GitHub Desktop.
match words in a list print
awk 'NR==FNR {a[$1]++; next} $1 in a' words myfile
grep -Fw -f words myfile
#* This would extract the lines in myfile that contains the words in the file words anywhere.
#The strings in words are treated as fixed strings (not regular expressions) due to the -F option, and the -w option ensures that we only get lines that contains the exact same word (no matches of substrings in words are allowed).
#The words in the file words most be listed on separate lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment