Hi my bash script says the that the first parameter passed into it doesn't exist as a file but it does. Please what have I done wrong?
to run the script and pass in two arguments from linux:
./concantenatefile.sh file1.txt file2.txt
#!/bin/bash
file1="$1"
if [ -e file1 ]
then
echo "The file $file1 exists"
else
echo "The file $file1 doesn't exist"
fi
It says
The file file1.txt doesn't exist
However there is a file called file1.txt in the present working directory.
if [ -e $file1 ]
- you missed the$
sigil before the variable name.