-1

I have been stuck for an hour now and still can't figure this out. FYI - I am new to the bash scripting. Here is what I am trying to do

var="Y"
while [ "$var" = "Y"]
do
echo "Hello World!!"
echo "Keep going? [Y/N]"
read var
done

I am getting an error in the while line (while [ "$var" = "Y"]) - I pretty much tried everything - with single ', double " - no "

2
  • Possible duplicate of stackoverflow.com/questions/12840769/… Commented Jan 24, 2015 at 8:40
  • Did you actually read and try to understand the error given? When I run your script I get: ./script: line 4: [: missing `]'. Trying to read the error message can help. Commented Jan 24, 2015 at 9:30

1 Answer 1

1

You need to provide a space next to "Y"

That is,

while [ "$var" = "Y" ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.