sh file if statement for user input Y/N

Hi i have created an sh script and need to create an if statement for user input Y or N,

i have tried the following

echo -n "Do you wish to move this file to the tmp directory?[Y/N]: "
read movefile

echo
if [$movefile == Y]; then
        echo "Moving File to tmp"
else
        echo "you can download the file from "
fi


please can someone correct this for me as when i run the script i get the responce

Do you wish to move this file to the tmp directory?[Y/N]: Y

./search_with_ref_input.sh: line 19: [Y: command not found
you can download the file from

thanks in advance
cghrmauritiusAsked:
Who is Participating?
 
woolmilkporcCommented:
if [ "$movefile" =  "Y" ]: then ...

Note the spaces and the quotes!

wmp
0
 
woolmilkporcCommented:
Sorry, there must be a semicolon ; following ] !

Those tiny Smartphone keys ...
0
 
cghrmauritiusAuthor Commented:
Thanks you so much for the quick response worked perfectly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.