First page Back Continue Last page Summary Graphic

Pipelines and Execution Series

  • | is used to direct the standard output of a command to the standard input of another.
  • && is used to conditionally execute a command based on the success of the prior command.
  • || is used to conditionally execute a command based on the failure of the prior command.
  • Note: Unlike what you may be used to, a return status of 0 (zero)
  • denotes success. Anything else signifies failure.
  • e.g.
  • [ -f nonexistentfile ] && cat nonexistentfile
  • [ -f nonexistentfile ] || echo 'No such file!'
  • --> No such file!
  • echo "hello there 1" | wc -c
  • --> 14
  • [ `echo 'hello there 1' | wc -c` -gt 13 ] && echo 'Success'
  • --> Success

    Notes: