0
if [ $USER=root ]; then echo "hi" else echo "bye" fi

it is giving me the following error

line 5: syntax error near unexpected token `fi'
line 5: `fi'
Vivek
13.6k19 gold badges101 silver badges139 bronze badges
asked Dec 8, 2015 at 6:46
1
  • maybe add a semicolon before else and fi? or just don't force all that poor code into one line. or if it's really just that small snippet consider using && and || instead. Commented Dec 8, 2015 at 7:21

1 Answer 1

1

The correct code: if [ $USER == "root" ]; then echo "hi; else echo "bye"; fi

answered Dec 8, 2015 at 6:54

1 Comment

== is the same as =

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.