I have three files foo1.txt, foo2.txt and foo3.txt, which contain the following lines
# foo1.txt
JOBDONE
and
# foo2.txt
Execution halted
and
# foo3.txt
Execution halted
JOBDONE
I have been able find the ones with both JOBDONE and Execution halted using:
find ./foo*.txt | xargs grep -l 'Execution halted' | xargs grep -l "JOBDONE"
But have not been able to find those files which have JOBDONE or Execution halted but not both. I have tried:
find ./foo*.txt | xargs grep -lv "JOBDONE" | xargs grep -l "Execution halted"
find ./foo*.txt -exec grep -lv "JOBDONE" {} \; | xargs grep -l "Execution halted"
but have been incorrectly (to my understanding) returning
./foo2.txt
./foo3.txt
What is wrong with my understanding of how xargs and exec works with grep and how do I use grep or another portable command to select those logs that have JOBDONE but not Execution halted or vice versa?