Results 1 to 2 of 2
Hello all. This is sending me crazy at the moment. I am writing a bash script that is suppose to log into a server, go to a directory nd check ...
- 07-30-2007 #1Just Joined!
- Join Date
- May 2006
- Posts
- 39
array in if body being evaluated reagrdless of condition..
Hello all. This is sending me crazy at the moment. I am writing a bash script that is suppose to log into a server, go to a directory nd check for the presence of a certain file, which is identified by a date stamp. so i do the following.
...
ssh bwill@theisland "
cd /home/ToTheIsland
if [ -e "${file1}" ];
then
echo here at file1. They exist
echo index is ${index}
: ${missing[$index]="${file1}"}
: $[index++]
else
echo file1 files does not exist!
fi
"
...
now my problem is that the array and the indrement in the body of the if gets assigned regardless of the value of the condition. only the echo behave how I expect. What is up with this? is this how bash works? is there a work around. Please help. Thanks..
-B
- 07-31-2007 #2
What is with all the brackets? It shoudl work if
Code:if [ -e "$FILE1" ]; then echo "Doing some **** to $FILE1" else echo "$FILE1 does not exist." fi


Reply With Quote