Shell: redirect stdout to /dev/null and stderr to stdout

Viewed 66611

I saw this interesting question at a comment on cyberciti.biz.

That I found I even can't find a flexible way to do this in one-line command with sh.

As far my thought for the solution is:

tmp_file=`mktemp`
(./script 2>$tmp_file >/dev/null; cat $tmp_file) | ./other-script
rm tmp_file

But you see, this is not synchronous, and fatally, it's so ugly.

Welcome to share you mind about this. :)

3 Answers
Related