Hi,
I have a script which will check the fiel existence, the lines are as below
if !(test -d ./data) then
mkdir data
fi
In the first line error occurs as below
generatelicense.sh: syntax error at line 2: `!' unexpected
Where as this script works fine in linux OS.
How to solve it?............................
Regards
Revathi
Your code does not work with the Bourne shell (/bin/sh) which is the default shell on most UNIX systems. This is the case for Solaris.
To maximize shell script portability, you should try and write all your shell scripts so that they work with the Bourne shell.
The following works:
if [ ! -d ./data ]
then
mkdir data
fi
As an aside it is good practice to use fully qualified pathnames i.e. /usr/bin/mkdir instead of just mkdir.
That's correct.
It works fine..............
Thanks
Revathi