# ./test.sh
aaaa
./test.sh: line 2: -e: command not found
NO SUCH FILE
# vi test.sh
# ./test.sh
asdfa
NO SUCH FILE
# cat test.sh
read file
if [ -e "$file" ]
then
echo "asfsafafa"
else
echo "NO SUCH FILE"
fi
#
After changing to [ -e "$file" ], it is working. Make sure there is a space between [ and -e.
If file is already present how you can make new file with same file name.
You should decide either you want create new file or append data into old file.
You can append data to that file
using
echo "data" >> $file
OR create new file
echo "data" > $file
and if your file name is having csv in it then you don't need to use $file.csv
and if you want to add extension use $file".csv"