0

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...

Dnaiel
  • 7,622
  • 23
  • 67
  • 126

2 Answers2

2

Join both conditions into something like this:

grep -f list.txt *.txt
fedorqui
  • 275,237
  • 103
  • 548
  • 598
0

As I understand, you only need names, so you need -l argument.

grep -l -f list.txt *.txt
Vytenis Bivainis
  • 2,308
  • 21
  • 28