redirecting output to multiple outputs
I want to redirect output to multiple places, how can this be done. Something simple as...
ls /etc redirected to both a file and monitor. I know how to redirect to a file and understand std output is monitor, but how do I do both in 1 command? ls /etc > file and then??? |
Code:
ls /etc/ 2>&1 | tee file |
sweet, thanks oliv, worked perfectly. What did the 2>&1 do though
|
If my memory is good: 2>&1 is used to duplicate stderr to stdout
|
that's what I though, but ls /etc isn't an err so why does it work. Wouldn't it just produce stnd out? Either way thanks Oliv!
|
It works because stdout remains stdout... You just add messages from stderr to stdout.
It's just a precaution if you process commands which can cause errors |
the 2>&1 means that both stdout and sterr to the pipe and then to the tee command and to the file
|
All times are GMT -5. The time now is 12:13 AM. |