0

This may have been asked before but I couldn't find it. I am grepping a lot of data files for "NaN" to search for errors; the problem is that if "NaN" appears once in a file, in all likelihood it will appear thousands of times and hence the output will be unmanageable. Specifically, the command

grep "NaN" *

yields about a gigabyte of output, virtually all of which is redundant. How do I suppress all the specific lines where "NaN" appears and instead print only the name of the file?

3
grep -l "Nan" *

Or, if you want to start nixing output, grep "NaN" * | grep -v ...

I probably should also mention another possible next step, which is

grep -l "NaN" * | xargs grep ...

as grep needs filenames to work on for a second pass with a new search term.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.