I've been looking inclusive I even checked the if manual for bash and tried in cli mode.
#!/bin/sh
CONFIG_DIR="/var/opt/SUNWldm/"
read option
if [ $option -eq 9 ]; then
ret=1
elif [ -e ${CONFIG_DIR}file.xml.${option} ]; then
echo "TRUE"
fi
I have the above code in a while loop to present a list of options. Unfortunately I'm having problems with the elfi statement.
From: IF for Beginners the -e returns true if the file exists.
I've double checked the syntax and even running the script in debug mode (I put set -x at the beginning of this script and could see that the replacement in the if is done properly as seen inline:
+ [ 201301271355 -eq 9 ]
+ [ -e /var/opt/SUNWldm/file.xml.201301271355 ]
./ldm_recover.sh: test: argument expected
I've been searching so far and haven't found a reason for failing, any ideas what I'm doing wrong?
/bin/sh, use/usr/xpg4/bin/shto get a standard shell./bin/shis only for backward compatibility for old scripts that rely on/bin/shbeing a Bourne shell and not a standardsh. – Stephane Chazelas Jan 28 at 12:10