Re: Bash equivalent to DOS /p
--- Nori Heikkinen <nori@sccs.swarthmore.edu> wrote:
> well, it is well-known, but i somehow always get the order of the
> ampersands and redirection >s messed up. why, for exapmle, is there a
> '&' in front of the '1' there, but not the '2'?
Shell redirection...
2> says to direct stderr
&1 means to duplicate it to stdout
so the result you get when doing 2>&1 is that _both_ standard output and
standard error are shown.
The caveat of course is when you do:
command 2>&1 > ./some_filename
will NOT work as expected since although it appears you're directing
stderr/stdout to "some_filename" what happens is that only stdout is sent
to "some_file". Why? Because stderr is duplicated (that's what the '&'
means) to stdout before stdout is directed to the filename. To get around
this:
command > ./some_filename 2>&1
The equivalent command, being:
command &> ./some_filename
-- Thomas Adam
=====
"The Linux Weekend Mechanic" -- http://linuxgazette.net
"TAG Editor" -- http://linuxgazette.net
"<shrug> We'll just save up your sins, Thomas, and punish
you for all of them at once when you get better. The
experience will probably kill you. :)"
-- Benjamin A. Okopnik (Linux Gazette Technical Editor)
___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com
Reply to: