What is the difference between
rm executable
and
rm executable >>dev/null
I had the later statement in a Makefile
and changed it to the first one. I had the impression that nothing changed.
rm executable
simply deletes the file executable
from the current directory.
rm executable &> /dev/null
does the same, but it runs the command with output and error streams redirected to the special file /dev/null
.
That means you will not see any messages in the terminal. The /dev/null
file they are redirected to instead is a virtual character device which simply swallows all incoming data like a black hole.
Output redirection to /dev/null
like this is often used in scripts where you don't want the user to see possible output of the contained commands.
This append line to /dev/null
only means that all output is omitted or better to say send directly into the data nirvana (or void, or bottomless pit). So the only thing that could change is that if this command runs into an error that you will see output for it on the screen.
rm executable &> /dev/null
instead? What you wrote should not work.rm a >>dev/null
appends only stdout to a local file callednull
in a local directory calleddev
. What you probably meant isrm a &> /dev/null
which redirects both stdout and stderr to the special character device /dev/null.rm a > /dev/null 2>&1
is the portable construct.