I want to check if a file exists, and if it doesn't exists, I want to ask the user if they'd like to create it. Whether the user inputs Y or N, only "Whatever you say" appears on the screen.
#!/bin/bash
#This is testing if a file (myFile) exists
if [ -f ~/myFile ]
then
echo "The file exists!"
else
echo "The file does not exist. Would you like to create it? (Y/N)"
read ANSWER
fi
if [ "$ANSWER"="N" ]
then
echo "Whatever you say!"
else
touch myFile
echo "The file has been created!"
fi