How to store standard error in a variable

后端 未结 18 2349
难免孤独
难免孤独 2020-11-22 12:46

Let\'s say I have a script like the following:

useless.sh

echo \"This Is Error\" 1>&2
echo \"This Is Output\" 

And I have an

18条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 13:44

    $ b=$( ( a=$( (echo stdout;echo stderr >&2) ) ) 2>&1 )
    $ echo "a=>$a b=>$b"
    a=>stdout b=>stderr
    

提交回复
热议问题