This is where I post snippets of information about Information Technology. It is mostly for my own reference but I hope that others will find it useful and comments are welcome.
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
No comments:
Post a Comment