Monday, September 19, 2011

Redirecting Input and Output

you can have Linux send output to a file instead of the screen. This process of routing your input and output through files is called input and output redirection.

You can redirect output to a special location called /dev/null when you want to get rid of the
output. When you use /dev/null as the output location, all messages issued during the execution of
a program are simply discarded and not recorded anywhere on the file system. The following example
shows how redirecting a file’s output to /dev/null make its contents disappear.

$ find /u02/a/b/c/ locate.txt -print

$ cat locate_bilal.txt

$ cat locate_bilal.txt > /dev/null

In this example, the first cat command shows you the output of locate_bilal.txt. However, after redi-
recting the cat command’s output to /dev/null, the output of the cat command disappears.

No comments:

Post a Comment