I would like to store in file all path files with a specific extract of file content where file contains AAA
but NOT BBB
.
I tried so many things but this try is close to my goal :
find /data/my_project -type f -name "*.php" -exec grep -q "AAA" {} \; -exec grep -L "BBB" {} \; -exec awk '/AAA/{print $NF}'> /tmp/tables_names.txt {} \; -print > /tmp/class_list.txt
But... Result contains file with sometimes AAA
only, AAA
AND BBB
..
EDIT :
This is pretty same question as Find files that contain a string and do not contain another but where there's no answer validated it was really difficult to read. 75 % of my answer was in fact there sorry... But, I would like to return not only matched files paths but an extract (piece of text) of this matched file !
AAA
but no files that containBBB
(even if they containAAA
). What would you want to do with them? I'm confused by yourawk
command. – Kusalananda Mar 07 '18 at 14:33