Wednesday, 21 August 2013

How can I combine grep with file and extra regex

How can I combine grep with file and extra regex

I have a file of strings in each line.
For example:
AAAAA
BBBBB
CCCCC
etc
I want to check each string one by one whether it exists in a series of
files in a specific directory.
I know that I can do: grep -f filename to do the search. But what I need
is to use one more regular expression per line to get more specific
results. The file with the strings is big and changes often so it does not
make sense to modify each line to add an expression.
So what I need is to combine the grep -f filename to loop over each line
of the file (and grep for it in the files) but add some more conditions.
E.g. that AAAAA exists and [0-9]{1,3}$ exists as well in the same line.

No comments:

Post a Comment