Create a file from within a script

Hi,

I want to create a file from within a script that checks whether the file itself exists or not. Like:

if [[ ! -e .theFile]] then
echo Creating file...
cat << EOF > .theFile
echo This line should be in the file
EOF
fi

If I run the script with no condition (commenting out the first and last line), it works. But if I try to create the file within the "if" I get the following error:

./test: syntax error at line 3 : `<<' unmatched

Any idea on how to work around this? Thanks in advance.

'test' need some space around :).

if [ ! -e .theFile ]; then
.....
fi

Lamano,

I tested it, it should work.
Give it a try and post it back here so others can benefit from it.

##################### work ###########
if test ! -f filename
then
echo File does not exit
echo Creating file...
touch filename
else
echo File exit. Do Nothing.
fi
############################## this works as well
# run the script by typing: sh script4.sh
# check: ls -alt
# cat the filename

if [ ! -s .theFile ]
then
echo Creating file...
cat << EOF > .theFile
echo This line should be in the file
EOF
fi