Let's suppose I want to find all .txt
files and search for some string. I would do:
find ./ -type f -name "*.txt" -exec egrep -iH 'something' '{}' \;
What if I want to do a more complex filtering, like this:
egrep something file.txt | egrep somethingelse | egrep other
Inside find -exec? (or similar)
Please keep in mind that I'm searching for a solution that I could easily type when I need it. I know that this could be done with a few lines using a shell script, but that isn't what I'm looking for.
xargs
could also be used asxargs -I {} sh -c '...' sh {}
, if one wanted to (it makes it possible to run parallel jobs with-P
if one wanted to). – Kusalananda Mar 18 '19 at 17:23sh
in the very end as in... sh {} \;
. Would you mind clarifying? @terdon – Boson Bear Mar 31 '22 at 14:03