Skip to content

Instantly share code, notes, and snippets.

@cftang0827
Last active September 1, 2022 11:55
Show Gist options
  • Save cftang0827/77820c4b55f0e607b155e74f25330918 to your computer and use it in GitHub Desktop.
Save cftang0827/77820c4b55f0e607b155e74f25330918 to your computer and use it in GitHub Desktop.
Grep from line separated file keywords
# https://stackoverflow.com/questions/1251999/how-can-i-replace-each-newline-n-with-a-space-using-sed
cat test | grep -E $(cat target | sed ':a;N;$!ba;s/\n/|/g')
# test
#
# Hey yoyo
# today is a good day
# word1 is good
# word2 is not good
# you are good
# hello world
# yayayay
# target
#
# word1
# word2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment