grep regex containing 'yyy' but not containing 'zzz' :
- First, finding all files containing 'yyy', and keep in one file
grep -r -l "yyy" /c/folder/ > grepsearch.txt
- Second, call this script : grepsearch.sh who is looping on first result file and search number of occurencies of the second search 'zzz'
for file in `cat grepsearch.txt`; do
# echo "---------------------------------------------------------- $file";
grepcount=$(grep -c 'zzz' $file);
# echo $grepcount $file;
if [ $grepcount -eq 0 ]
then
# echo "No matching search zzz";
echo $file;
# else
# echo "Match search zzz";
fi
done
Note : if your search contain "\" add a second : "\\"