Search text in list of files. Double search. Search files within a files

Posted by wormhit on Super User See other posts from Super User or by wormhit
Published on 2011-11-23T09:15:18Z Indexed on 2011/11/23 9:55 UTC
Read the original article Hit count: 169

Filed under:
|
|
|
|

I'm trying to execute double search within files and return file names.

I'm using

find ./ -iname '*txt' | xargs grep "searchtext" -sl

to find file names with 'searchtext' in them.

Command is returning a list of files.

How can I find "othersearchtext" in those already found files and show them in the same fashion?

#### EDITED

Answer:

grep -l "othersearchtext" $(find ./ -iname '*txt' | xargs grep "searchtext" -sl)

© Super User or respective owner

Related posts about linux

Related posts about bash