You're viewing a comment by Alan and its responses.

September 11, 2012, 14:16

Thanks for a comprehensively informative article on a (traditionally) confusing area.

I tried out some of the commands, and nearly made it all the way to the end. Separation of stderr and stdout (point 22 in article) led to actual output which differed from expected though. I tried this:

$ touch one.txt
$ rm -rf two.txt
$ ls one.txt two.txt > >(sed "s/^/O /") 2> >(sed "s/^/E /")
O one.txt
O E /bin/ls: cannot access two.txt: No such file or directory

On that final line I was expecting it to start with "E /bin/ls ...". Any ideas why the actual output starts with "O E /bin/ls ..." instead?

Comment Responses

September 11, 2012, 14:19

P.S.: Same behaviour on bash 3.1.17, 3.2.48 and 4.1.5

raphael Permalink
September 11, 2012, 17:52

$ ls one.txt two.txt > >(sed "s/^/O /") 2> >(sed "s/^/E /" 1>&2)
O one.txt
E /bin/ls: cannot access two.txt: No such file or directory

This does the trick. But don't ask me why, it was just a guess.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "cloud_329": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.