What is the difference between the following commands?
ssh myhostname "command1; command2;...commandn;" 2>/dev/null ssh myhostname "command1; command2;...commandn;"
what does 2>
mean?
what does /dev/null
mean? I read somewhere that result of command will be write to file /dev/null
instead of console! Is it right? It seems strange for me that the name of file be null
!
/dev/null is a null device–a special type of virtual device. It is present in every Linux system, and the purpose of this device is to discard anything sent to it and read the End of File (EOF). Most virtual devices are used to read data; however, /dev/null is unique since it is used to suppress any data written to it.
It means that stderr ( 2 - containing error messages from the executed command or script) is redirected ( >& ) to stdout ( 1 - the output of the command) and that the latter is being redirected to /dev/null (the null device). This way you can suppress all messages that might be issued by the executed command.
To begin, /dev/null is a special file called the null device in Unix systems. Colloquially it is also called the bit-bucket or the blackhole because it immediately discards anything written to it and only returns an end-of-file EOF when read.
/dev/null is the null file. Anything written to it is discarded. Together they mean "throw away any error messages". Follow this answer to receive notifications.
2>
means "redirect standard-error" to the given file.
/dev/null
is the null file. Anything written to it is discarded.
Together they mean "throw away any error messages".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With