I have a list of search terms in termlist.txt, and a directory /dir/scripts which has a lot of scripts inside.
How would I easily determine if any file in /dir/scripts contains any term in the list from terms.txt?
This is on a unix server.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityI have a list of search terms in termlist.txt, and a directory /dir/scripts which has a lot of scripts inside.
How would I easily determine if any file in /dir/scripts contains any term in the list from terms.txt?
This is on a unix server.
grep -Fxrlf termlist.txt /dir/scripts
where grep options are
-f file
use patterns from file-F
patterns are fixed strings, not regular expressions-x
the pattern must match the whole line (you may not want this)-l
output only the filenames containing the match-r
recursive