I know that this is a ridiculously simple statement, but I am getting an error when I execute it, and I can't figure out what it is. Can anyone point me in the right direction?
#!/bin/ksh
integer dateMonth=0
integer intZero=0
if [$dateMonth == $intZero]
then
dateMonth = 1
fi
echo $dateMonth
if [$dateMonth == $intZero]
needs to be
if [ $dateMonth == $intZero ]
Notice the spaces after "[" and preceeding "]"
Thomas
I've actually tried that, with no success. The error I get is "dateMonth: not found". It then proceeds to echo "0".
dateMonth = 1
No spaces around the equals sign
When I take out those spaces, the error I get is "[0: not found". And then it still proceeds to echo "0".
Sorry I didn't notice this as well.
dateMonth = 1
needs to be
dateMonth=1
Thomas
either
if [ $dateMonth -eq $intZero ]
OR
if (( dateMonth = intZero ))
Integer typing is needed in programming languages. Shell scripts no support is there for it. Try as,
#!/bin/ksh
# let assings value to that variable
let dateMonth=0
let intZero=0
# Space needed [[<space> and <space>]]
if [[ $dateMonth -eq $intZero ]]
then
# Don't put space between =, variable and data
dateMonth=1
fi
echo $dateMonth
Execute this. It will work. Plz. refer more online ksh scripting docs before starting it.
All the best.
HTH.