scope of variable in pipe

后端 未结 6 1483
余生分开走
余生分开走 2020-12-18 10:51

The following shell scrip will check the disk space and change the variable diskfull to 1 if the usage is more than 10% The last echo always shows

6条回答
  •  时光取名叫无心
    2020-12-18 11:20

    In this line:

    usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
    

    it's not necessary to use cut. You can do this:

    usep=$(echo $output | awk -F% '{ print $1}' )
    

提交回复
热议问题