Seen this? You will ask either of the following question:
1) What is it?
2) I know it is input/output redirection but how is it working?
Now the answer for both of you.
In *nix world STDIN, STDOUT, STDERR are three common things that you must know.
Standard Input i.e. STDIN or 0 is something like keyboard.
Standard Output i.e. STDOUT or 1 is something like Monitor
Standard Error i.e. STDERR or 2 is something like ERROR
You can manipulate them. For eg,
Instead of typing from keyboard you can input from other medium using input redirection.
Like print < /file
Instead of displaying to monitor you can output to other medium using output redirection. Like echo something > /otherfile
You can use >> to append
Instead of displaying error to standard error you can use error redirection.
Like cat somefile 2> /dev/null
cat somefile 2> /somefile
Here /dev/null is something like dustbin. If you don't want your error to be seen then simply redirect it to the dustbin.
Now let me answer the second question
> /dev/null 2>&1 redirect both output and error to /dev/null
> /file 2>&1 redirect both output and error to /file
Explanation:
> redirects output to /dev/null
2>&1 redirect error to where > is redirected
So error also gets redirected to /dev/null
10RIBU FACEBOOKER INDONESIA PASTI MENYUKAI FANS PAGE JAMTANGANKANAN
-
Anda pingin tau UPDATE an TERBARU atau INFO-INFO TERBARU dari PRODUK
KAMi dan Bisa Berinteraksi dengan kami bahkan PELANGGAN SETIA KAMI yuk
"SUKA"
FANS PA...
12 years ago
No comments:
Post a Comment