[KLUG Members] Huh

Adam Williams members@kalamazoolinux.org
04 Aug 2002 17:01:45 -0400


>How long did I sit there scratching my head wondering how to make
> if $COMMAND | logger
>    then
>    this
> else
>    that
> fi
> use the return status of the first command before I realized that 
> if $COMMAND
>    then
>    this
> else
>    that
> fi | logger
> Was all I needed to do?? Sheesh.

Yep,  flow control structures amalgamate the output of all their
'contents' as if you used parens "(ls; who; ps ax) | more".  Very handy
in for loops especially:

for FILE in `ls spool*`
do
  echo "-[SPOOL FILE: " $file "]"
  uuencode $FILE
  echo
done | mail -s "Spooled Messages' india