I'm wondering how to control where my if statements find files.
The code if [ -e filename ]
should find a file, but where is it looking?
I have the following code I'm having trouble with:
#!/bin/bash
#create a new file
echo "Enter the customer data"
read -p "Email:" cemail
read -p "Name:" cname
read -p "Apt:" capt
read -p "Monthly Rent:" crent
read -p "Rent Due Date:" cdatedue
echo "$cemail"
#if its already a file then error
if [ -e "$cemail" ]
then
echo "Error: customer already exists"
exit 1
else
echo "ok"
fi
when I type in a filename that does exist it still isn't finding it. Our programs are in the
:~/courses/cs3423/2017Fa/Proj1
folder and the files we are searching against are in the
:~/courses/cs3423/2017Fa/Proj1/Data
folder. And this is how the program has to be set up as well. How can I manipulate the if to function correctly, or do I need to use something else? Thanks.