Tuesday, February 08, 2011

if statement with -a (and) operator

#!/bin/sh
DCDIR=/usr/data

lc=unknown
if [ -e /etc/config/local/lc.cfg ]
then
        lc=`cat /usr/XX/config/local/lc.cfg`
fi

if [ "$lc" != "prod" -a "$lc" != "stage" -a "$lc" != "dev" ]
then
        echo "ERROR $0 bad lc of $lc"
        exit 1
fi

echo "Good lc $lc"

No comments:

Post a Comment