Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "/dev/null" mean at the end of shell commands

Tags:

linux

shell

What is the difference between the following commands?

ssh myhostname "command1; command2;...commandn;" 2>/dev/null ssh myhostname "command1; command2;...commandn;"  
  1. what does 2> mean?

  2. 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!

like image 411
Sepehr Samini Avatar asked Nov 16 '12 00:11

Sepehr Samini


People also ask

What is the point of Dev 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.

What does >/ dev null 2 >& 1 mean?

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.

What happens if you read Dev null?

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.

What is the meaning of null shell?

/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.


1 Answers

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".

like image 139
Michael Lorton Avatar answered Sep 30 '22 22:09

Michael Lorton