Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To prevent grep from displaying errors saying 'No such file or directory', you can use the '-s' or '--no-messages' option.

For example, instead of using:

grep "search pattern" file_that_does_not_exist.txt

Use:

grep -s "search pattern" file_that_does_not_exist.txt

or

grep --no-messages "search pattern" file_that_does_not_exist.txt

This will suppress error messages and display only the matching lines from the files that do exist.