How to hide output of shell

There are three IO devices available on the command line.

 standard in - 0 
 standard out - 1 
 standard error - 2

To redirect standard out (the default output) to a file (and overwrite the file), use

 command > file.log

To append to file.log, use 2 >s

 command >> file.log

to redirect standard error to the file.log, use

 command 2> file.log

and to append

 command 2>> file.log

To combine the outputs into one stream and send them all to one place

 command > file.log 2>&1

This sends 2 (stderr) into 1 (stdout), and sends stdout to file.log

Notice that it’s also possible to redirect standard in into a command that expects stdin

 command << file.txt
Advertisements
Posted in Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: