19.03.2015 Views

Unix Tutorial

test

test

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Here command is the name of the command you want to execute. The file /dev/null is a special file that<br />

automatically discards all its input.<br />

To discard both output of a command and its error output, use standard redirection to redirect STDERR to<br />

STDOUT:<br />

$ command > /dev/null 2>&1<br />

Here 2 represents STDERR and 1 represents STDOUT. You can display a message on to STDERR by<br />

redirecting STDIN into STDERR as follows:<br />

$ echo message 1>&2<br />

Redirection Commands:<br />

Following is the complete list of commands which you can use for redirection:<br />

Command<br />

pgm > file<br />

pgm < file<br />

pgm >> file<br />

n > file<br />

n >> file<br />

Description<br />

Output of pgm is redirected to file<br />

Program pgm reads its input from file.<br />

Output of pgm is appended to file.<br />

Output from stream with descriptor n redirected to file.<br />

Output from stream with descriptor n appended to file.<br />

n >& m Merge output from stream n with stream m.<br />

n

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!