I am running the same job on around 1000 input files. Around 10% of these will fail, but the only way of checking this is to scroll through the output files and check if it states completed without error. To save time is there a way of using the grep command to

  • Search in a directory specifically through output files only (named oxxxxx),
  • for those that do not contain the phrase completed without error,
  • listing these oxxxx files in the terminal window.

Thank you!


2 Answers 2


Using GNU grep's -L extension:

grep -L 'completed without error' o*

-L, --files-without-match

Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The scanning will stop on the first match.

Without GNU grep:

for f in o*; do grep -q "completed without error" "$f" || printf "%s\n" "$f"; done
  • The "without GNU" example should also include o* as the target files for OP's case Apr 14, 2018 at 12:15
grep -R <pattern> -L *

-R      recursively search
-L      files without match    


 touch $(seq 1 100)  # create 100 files
 echo "testing" > 28
 echo "testing" > 32
 echo "testing" > 10
 echo "testing" > 15
 echo "testing" > 95
 echo "testing" > 72
 echo "testing" > 34
 echo "testing" > 25 # eight files with pattern
 $ grep -l test *|wc -l  # files that contains pattern
 $ grep -L test *|wc -l  # files that doesn't contain pattern

Not the answer you're looking for? Browse other questions tagged .