Home > Ubuntu / Linux > Linux Command-line : Some useful Redirection techniques

Linux Command-line : Some useful Redirection techniques

Redirecting Standard Output
[me@linuxbox ~]$ ls -l /usr/bin > ls-output.txt

Append redirected output to a file instead of overwriting the file from the beginning
[me@linuxbox ~]$ ls -l /usr/bin >> ls-output.txt

Redirecting Standard Error
[me@linuxbox ~]$ ls -l /bin/usr 2> ls-error.txt

Redirecting Standard Output And Standard Error To One File
[me@linuxbox ~]$ ls -l /bin/usr > ls-output.txt 2>&1
OR
[me@linuxbox ~]$ ls -l /bin/usr &> ls-output.txt

Disposing Of Unwanted Output
[me@linuxbox ~]$ ls -l /bin/usr 2> /dev/null

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

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: