Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sh file if statement for user input Y/N

Posted on 2011-02-13
3
Medium Priority
?
663 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:cghrmauritius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 34885775
if [ "$movefile" =  "Y" ]: then ...

Note the spaces and the quotes!

wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34885780
Sorry, there must be a semicolon ; following ] !

Those tiny Smartphone keys ...
0
 

Author Closing Comment

by:cghrmauritius
ID: 34885789
Thanks you so much for the quick response worked perfectly
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question