Does your script even run? Doesn't look like valid bash-script to me. If
is not a valid keyword, but if
is. Also, tests go inside angle-brackets [
]
, those are not optional. Moreover you forgot the closing fi
.
And another thing, it's not quite clear to me what you're testing for. Is directorypathANDfilename
a variable? In that case you have to reference it with the $
.
The snippet would probably work better like this:
#!/bin/bash
if [ -f "$directorypathANDfilename" ] ; then
read -p "A file with the same name exists, Overwrite it? Type y/n?" yesorno
case "$yesorno" in
y*) therestore ;;
n*) echo "File has not been restored" ;;
esac
fi