Reputation: 7832
Let us say I have a list of files with extension .txt.
And I'd like to know what is the name of the files that match a regex pattern, how would I do that in linux.
Right now I am doing:
cat *.txt | grep -f list.txt
where list.txt contains a list of regex patterns.
This command only shows me that the pattern was matched but I cannot see the name of the file that matched it...
Upvotes: 0
Views: 128
Reputation: 2376
As I understand, you only need names, so you need -l
argument.
grep -l -f list.txt *.txt
Upvotes: 0
Reputation: 289555
Join both conditions into something like this:
grep -f list.txt *.txt
Upvotes: 2