I wish to pass each line of a file as a grep pattern to be searched in data.txt file.
Thus, i need cat allsearchstrings.txt | grep <should be lines of allsearchstrings.txt> data.txt
cat allsearchstring
: 'CANV'
: 'CANV_MATCH'
: 'MY'
I think xargs
could be the solution but I'm not sure how-to.
Note: the content of allsearchstrings.txt may have single quotes '
Could you please suggest?
grep
should be able to read patterns from a file directly (with the-f
option)complex_command | grep -F -f - data.txt
orgrep -F -f <(complex_command) data.txt
if your shell supports process substitutionI wish to pass each line of a file as a grep pattern
and usingcat allsearchstrings.txt
as an example. That doesn't line up with what's actually going on and makes it more difficult for people to answer your question.