cat file.txt | xargs grep 'pattern'

Category: I/O Redirection & Pipes

cat file.txt | xargs grep 'pattern'

Use xargs to pass file lines as arguments to grep

Passes each line of a file as a separate argument to grep, using xargs to bridge the pipe.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.