简体   繁体   中英

How can I search for a file that contains a pattern and then search within all those files with another pattern?

Basically, I want to do something like:

Locate log4j.xml 

which will give me over 20 results. Then I want to search within all these files for "iwjboss".

Is there a command that locates and then finds text within all these files bearing in mind that I don't know the directory of all the log4j.xml files?

用某事的结果做某事是这样实现的:

grep iwjboss `locate log4j.xml`

Yes there is a command it is called find .

Try this command for find and grep combined:

find . -name "log4j.xml" -exec grep "iwjboss" '{}' \;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM