By Paul Tero CHAPTER 8
$ find / -type d -name "smashingmagazine"
find: '/var/run/cups/certs': Permission denied
find: '/var/run/PolicyKit': Permission denied
/var/www/vhosts/smashingmagazine.com
/var/www/vhosts/smashingmagazine.com/httpdocs...
If you run this command as a normal unprivileged user, you will
probably see lots of “Permission denied” as find tries to explore forbidden
places. You are actually seeing two types of output here: stdout for
standard output and stderr for standard error. They are called output
streams and are confusingly mixed together.
You have already encountered the pipe symbol | for piping the output
stream (stdout) of one command into the input stream (stdin) of another.
The symbol > can redirect that output into a file. Try this command to send
all the matches into a file called matches.txt:
$ find / -type d -name ^"smashingmagazine" > matches.txt
find: '/var/run/cups/certs': Permission denied
find: '/var/run/PolicyKit': Permission denied...
In this case, all the stdout is redirected into the file matches.txt and only
the error output stream stderr is displayed on the screen. By adding the
number 2 you can instead redirect stderr into a file and just display stdout:
$ find / -type d -name ^"smashingmagazine" 2> matcherrors.txt
/var/www/vhosts/smashingmagazine.com
/var/www/vhosts/smashingmagazine.com/httpdocs...
There is a special file on Linux, UNIX and Mac computers which is
basically a black hole where stuff gets sent and disappears. It’s called /dev/
null, so to only see stdout and ignore all errors:
$ find / -type d -name ^"smashingmagazine" 2> /dev/null
/var/www/vhosts/smashingmagazine.com
/var/www/vhosts/smashingmagazine.com/httpdocs...