If you have used find command on Linux, you probably have encountered the case where the command ends up producing an endless list of warning or error messages in its output, because you are "permission denied" to access certain files or directories.
find: `./proc/18/task/18/fd': Permission denied find: `./proc/18/task/18/fdinfo': Permission denied find: `./proc/18/task/18/ns': Permission denied find: `./proc/18/fd': Permission denied find: `./proc/18/fdinfo': Permission denied find: `./proc/18/ns': Permission denied
Such output is probably meaningless to you, so you may want to exclude these warning or error messages from the output, and get actual search result only. How can you suppress warnings or errors, and only get search result in find command?
The find command sends any error or warning message to standard error output (i.e., stderr). So all you have to do to suppress these messages is to redirect stderr to /dev/null.
The following is how to suppress all warnings or errors in find command.
If you want to capture stderr output in a separate file for later inspection, you can do the following instead.
If you want to exclude specific warnings only, you can filter out warning messages from stderr selectively by using grep, instead of redirecting the whole stderr. For example:
The above command will suppress only "Permission denied" warning message, and show any other warning or error messages unfiltered.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!