[u-u] Sams book

John Sellens jsellens at syonex.com
Fri Jan 15 23:25:22 EST 2016

On Fri, 2016/01/15 10:38:43AM -0500, Jim Mercer <jim at reptiles.org> wrote:
| if your shell scripting depends on new features, you are doing it wrong.

I'm a stick in the mud, but I have on occasion started a script
with #!/bin/bash in order to be able to use $PIPESTATUS
e.g. if a command generates noisy useless output

    noisycommand | grep -v noise
    if [ $PIPESTATUS[0] -ne 0 ]; then
	echo noisycommand failed

Or similarly when logging output to syslog and also to stdout/stderr
    command 2>&1 | logger -s
    if [ $PIPESTATUS[0] -ne 0 ]; then
	echo command failed

Otherwise a temporary intermediate file, or saving output into a variable
is needed.


More information about the u-u mailing list