Skip to main content
added 24 characters in body
Source Link
Sparhawk
  • 20.5k
  • 20
  • 97
  • 160

I normally just use command substitution, then put it in a test, e.g.

if [ ! -z "$(command1 | command 2 | awk '$1 > 800')" ]; then command3; fi

##Explanation

  • This runs the command as per your question: command1 | command 2 | awk '$1 > 800'
  • The output of this is passed to the test [ ! -z "$(…)" ], which will be true if it is not ! a string of zero length -z.

Hence, if there is output to the command pipe, thenthe then commands will run.

I normally just use command substitution, then put it in a test, e.g.

if [ ! -z "$(command1 | command 2 | awk '$1 > 800')" ]; then command3; fi

##Explanation

  • This runs the command as per your question: command1 | command 2 | awk '$1 > 800'
  • The output of this is passed to the test [ ! -z "$(…)" ], which will be true if it is not ! a string of zero length -z.

Hence, if there is output to the command pipe, then

I normally just use command substitution, then put it in a test, e.g.

if [ ! -z "$(command1 | command 2 | awk '$1 > 800')" ]; then command3; fi

##Explanation

  • This runs the command as per your question: command1 | command 2 | awk '$1 > 800'
  • The output of this is passed to the test [ ! -z "$(…)" ], which will be true if it is not ! a string of zero length -z.

Hence, if there is output to the command pipe, the then commands will run.

Source Link
Sparhawk
  • 20.5k
  • 20
  • 97
  • 160

I normally just use command substitution, then put it in a test, e.g.

if [ ! -z "$(command1 | command 2 | awk '$1 > 800')" ]; then command3; fi

##Explanation

  • This runs the command as per your question: command1 | command 2 | awk '$1 > 800'
  • The output of this is passed to the test [ ! -z "$(…)" ], which will be true if it is not ! a string of zero length -z.

Hence, if there is output to the command pipe, then