Find files containing "abc" but not "edf"

Beginners question again, apologies.

I am looking for the configuration files which include “dhcp” but not “PERSISTENT_DHCLIENT”.

In the example below I have 8 configuration files, 3 of them include the line containing “dhcp”, 1 file includes “PERSISTENT_DHCLIENT”.

I am looking to combine last 2 relevances together (files which conatin “dhc” but not “PERSISTENT_DHCLIENT”).

Q: find files “ifcfg*” of folder "/etc/sysconfig/network-scripts"
A: /etc/sysconfig/network-scripts/ifcfg-bond0
A: /etc/sysconfig/network-scripts/ifcfg-bond1
A: /etc/sysconfig/network-scripts/ifcfg-eth0
A: /etc/sysconfig/network-scripts/ifcfg-eth1
A: /etc/sysconfig/network-scripts/ifcfg-eth2
A: /etc/sysconfig/network-scripts/ifcfg-eth3
A: /etc/sysconfig/network-scripts/ifcfg-eth4
A: /etc/sysconfig/network-scripts/ifcfg-lo
T: 3801

Q: lines containing “dhc” of find files “ifcfg*” of folder "/etc/sysconfig/network-scripts"
A: BOOTPROTO="dhcp"
A: BOOTPROTO="dhcp"
A: BOOTPROTO="dhcp"
T: 801

Q: lines containing “PERSISTENT_DHCLIENT” of find files “ifcfg*” of folder "/etc/sysconfig/network-scripts"
A: PERSISTENT_DHCLIENT=1
T: 783

Thank you,
Aleksandr

Try

find files whose (exists lines containing "dhcp" of it and not exists lines containing "PERSISTENT_DHCLIENT" of it) of folder "your folder"

You might get some false (mis)matches though if these strings are contained on comment lines.

Jason,
Thank you!

This looks good:

Q: find files “ifcfg*” whose (exists lines containing “dhcp” of it and not exists lines containing “PERSISTENT_DHCLIENT” of it) of folder "/etc/sysconfig/network-scripts"
A: /etc/sysconfig/network-scripts/ifcfg-bond0
A: /etc/sysconfig/network-scripts/ifcfg-bond1
T: 4420

Thank you,
Aleksandr