![]() |
what does "standard error was duplicated as standard output" mean?
here:
http://www.gnu.org/software/bash/man...ref.html#SEC37 it says: Code:
ls 2>&1 > dirlistQuote:
|
It means that error messages was send to standard error and standard output simultaneosly
|
ok, so that means that standard error messages were printed to the screen first (or at least directed to the screen, in the case that there were any errors), then the standard output (if there was any) would be directed to the file? maybe this is a dumb question, but can you ever get standard errors and output at the same time? or is it always one or the other?
|
Quote:
"2" is "stderr" a.k.a. "standard error" "1" is "stdout" a.k.a. "standard output" ">" can be thought of as "sent to" "&" can be thought of as "the same place as" By default, "1" is normally sent to your screen. So is "2". To send "standard output" to a file named "dirlist", you would do this: 1>dirlist Read this as: Code:
"standard output" + "sent to" + "dirlist"Looking at the text string "2>&1", this can be read as: Code:
"standard error" + "sent to" + "the same place as" + "standard output"The first case directs 2 into the same place as 1, and then directs 1 into dirlist. But at the time 2 was sent to the same place as 1, 1 was going to it's default. Your screen. But 2 goes to your screen by default too! So that operation didn't really do anything. In the second case, 1 was directed to dirlist first, and then 2 was directed to the same place as 1. So 2 would then go to dirlist also. So to capture both stdout and stderr to a file, first direct 1 to the file, then direct 2 to the same place as 1. e.g., ls >dirlist 2>&1 |
ok. got it. thank you very much haertig!
what i didn't see at first was the second ">": Code:
ls 2>&1 >dirlistCode:
ls 2>&1 1>dirlist |
| All times are GMT -5. The time now is 05:00 PM. |