Try
Code:
for file in file1 file2 file3;do
[ "$(sed -n '/eth0/{/eth1/! {=;q}}' "$file")" ] && echo "$file"
done
-n Suppresses normal sed output.
/eth0/{/eth1/! At any line containing eth0 but not eth1.
= Print the line number.
q Quit searching the file.
sed either prints a single line number or nothing, and that determines whether or not the file name is echoed.
This searches the current directory recursively.
It works with file names containing spaces.
Code:
while read file;do
[ "$(sed -n '/eth0/{/eth1/! {=;q}}' "$file")" ] && echo "$file"
done < <(find . -type f -print)