gibney.org : Technology : Linux : find files that contain string1 but not string2


just a logo :)

search:


See as: raw | code

terms of service | imprint

gibney.org
is powered by m1d1





find files that contain string1 but not string2
(Entry Nr. 1686, by user 1 | edit)
find . -name '*.txt' -exec awk '/string1/{f=1}/string2/{c=1;exit}END{exit !f ||c }' {} \; -print

other ways that could work:

find . -name *.php | xargs grep -l string1 | xargs grep -L string2

find . -name '*.php' -exec bash -c 'grep string1 "$1" && grep string2 "$1" || echo "$1"' _ {} \;
Create a new entry at this position