How to check exit if used tee?

前端 未结 3 1243
终归单人心
终归单人心 2021-01-19 06:55

I try to use tee to save output in file like:

myapp | tee log.txt

But I have a problem with checking of exit. Previous code:



        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-19 07:48

    Use PIPESTATUS

    myapp | tee log.txt
    if [ $PIPESTATUS[0] -eq 0 ] 
    then .....
    

提交回复
热议问题