I am writing a bash script that asks the user for a file name, then gives the user the option to copy, move or delete a file. Unfortunately when I execute the script, I keep getting errors saying "./Script3.txt: line 19: [: ==: unary operator expected". I have tried putting double quotes around my $option variables; as seen on stackoverflow, as well as using x"$option" but am still not understanding why I'm getting these errors.
echo "Please enter a file name: "
read fileName
if [ -f $fileName ]; then
echo "Enter C, M or D to Copy, Move or Delete a file: "
read fileName
if [ $option == "C" ]; then
echo "Where would you like to copy $fileName to?: "
read folderName
if [ -d $folderName ]; then
cp $fileName $folderName
echo "$fileName has been copied to $folderName"
fi
fi
elif [ $option == "M" ]; then
echo "Where would you like to move $fileName to?: "
read folderName
if [ -d $folderName ]; then
mv $fileName $folderName
echo "$fileName moved to $folderName"
fi
elif [ $option == "D" ]; then
echo "You are about to delete a file"
rm $fileName
else
echo "This is an invalid option. Please enter C, M or D"
fi