Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want one or two line description about the following command line:

grep -i '\/support\/security\/bulletins\/' content 2>/dev/null 
share|improve this question
add comment

3 Answers 3

up vote 10 down vote accepted

The > operator redirects the output usually to a file but it can be to a device. You can also use >> to append.

If you don't specify a number then the standard output stream is assumed but you can also redirect errors

> file redirects stdout to file
1> file redirects stdout to file
2> file redirects stderr to file
&> file redirects stdout and stderr to file

/dev/null is the null device it takes any input you want and throws it away. It can be used to suppress any output.

share|improve this answer
add comment

In short, it redirects stdout (fd 2) to the black hole (discard output of the command).

Some more common use case

command > /dev/null 2>&1 &

run command in background, discard stdout and stderr

command >> /path/to/log 2>&1 &

run command and redirect stdout and stderr to log file

share|improve this answer
add comment

This grep command has a wrong syntax, It should be something like

grep -ri content /support/security/bulletins/ 2> /dev/null

and the 2> /dev/null means to redirect all errors produced by this command to /dev/null, that is discard them, and don't display them to the screen (or where the standard error file descriptor is currently pointing). /dev/null is a file that when you write data to it they go nowhere.

share|improve this answer
    
There is absolutely nothing wrong if you use 2>/dev/null. These 2 are equivalents: > file and >file. And why grep -ri? –  Radu Rădeanu Sep 26 '13 at 9:02
    
By the way, he could also be looking for the string /support/security/bulletins/ in the file called content =). –  Alaa Sep 26 '13 at 9:06
    
@RaduRădeanu the wrong syntax is not on 2> but he has probably reversed the grep arguments, since otherwise grep is unlikely to produce lots of errors, except not being able to open a file named "content". –  sivann Sep 27 '13 at 12:24
    
@sivann That's a bad assumption. So, where is the wrong syntax? The OP doesn't said nothing about this... He just wanted to know what it means 2>/dev/null –  Radu Rădeanu Sep 27 '13 at 15:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.