[CLUE-Tech] shell programming

Lynn Danielson lynn.danielson at clue.denver.co.us
Wed Dec 11 15:21:00 MST 2002


On Wed, 2002-12-11 at 04:13, David Guntner wrote:
> 
> #!/bin/bash
> 
> if [ $LOGNAME = "root" ]; then
>   echo "Hello root"
> else
>   echo "You aren't root"
> fi

A minor point about the test statement. It is more important to
quote your variables rather than your constants.  For example,
[ "$LOGNAME" = root ].  Then if your variable is null, the test
won't throw an error.

Fwiw,

Lynn




More information about the clue-tech mailing list