Redirect stdout and stderr to Function

后端 未结 6 1260
滥情空心
滥情空心 2020-12-25 14:07

I need help sending the output (stdin and stdout) from system commands to a bash function, while still accepting input from arguments. Something like the example that follow

6条回答
  •  被撕碎了的回忆
    2020-12-25 14:38

    There are 2 ways of doing so, first, which I think is better, is to create a bash file and pass the result to it like this:

    make 2>&1 > ./LogMsg
    

    the second way is to pass result as an argument to function:

    LogMsg $(make 2>&1)
    

提交回复
热议问题