redirecting/ hiding standard out/ standard error (bash redirection)

find /some/dir -iname *some-substring* 2> /dev/null
Will not display any errors (e.g., inaccessible files or directories) but redirect stderr to ‘nowhere’ (2> /dev/null). 2> file.txt will redirect stderr to a file. The same is possible for stdout: > file.txt will redirect stdout to a file. To redirect both, use: &> file.txt will redirect stdout and stderr to the same file. To suppress both, use: &> /dev/null.
Share itShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *