Home > Syntax Error > Syntax Error Near Unexpected Token 'then'

Syntax Error Near Unexpected Token 'then'

Contents

Why is the Vitamin B complex, a "complex"? Join them; it only takes a minute: Sign up syntax error near unexpected token `then' [duplicate] up vote 0 down vote favorite This question already has an answer here: Why should TV episode or movie where people on planet only live a hundred days and fall asleep at prescribed time Is the partition function of non-conformal theories on a torus modular invariant? Because otherwise it will not be recognized as a parameter of its own. navigate here

By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Any command of any length to be precise. Remnants of the dual number Joining two lists with relational operators What are the downsides to multi-classing? UNIX is a registered trademark of The Open Group.

Syntax Error Near Unexpected Token Then' In Shell Script

I have various flavors of Linux. Not the answer you're looking for? Is it unethical to take a photograph of my question sheets from a sit-down exam I've just finished if I am not allowed to take them home? if [ $weight1 -gt $weight2 ]; then echo "Weight 2 should be greater than Weight 1." else if [ $weight1 -ge 20 ] && [ $weight1 -le 39 ]; then echo

share|improve this answer edited Aug 22 '13 at 22:36 answered Aug 22 '13 at 11:56 lesmana 10.2k63960 That was spot on, however now I am getting test.sh: line 6: I doing all of that I also removed the ; before the then as well. share|improve this answer answered Aug 22 '13 at 12:03 val0x00ff 3,9071824 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign Syntax Error Near Unexpected Token (' Bash Square root image filter tool in Python Why would a NES game use an undocumented 1-byte or 2-byte NOP in production?

As gman said, you need to better handle the comparison strings inside the brackets, likely by using double quotes. Syntax Error Near Unexpected Token Then' In Unix Square root image filter tool in Python What does "put on one's hat" mean? Will majority of population dismiss a video of fight between two supernatural beings? Click Here to receive this Complete Guide absolutely free.

For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. Syntax Error Near Unexpected Token `elif' However, people who install this plugin with an old version of rbenv will get the cryptic error if you merge my PR back in. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the Thanks for all the work on rbenv proper!‚Äč Sign up for free to join this conversation on GitHub.

Syntax Error Near Unexpected Token Then' In Unix

The reason for the spaces after [ is because [ is also not syntax. LinuxQuestions.org > Forums > Linux Forums > Linux - Server syntax error near unexpected token `then' User Name Remember Me? Syntax Error Near Unexpected Token Then' In Shell Script Help my maniacal wife decorate our christmas tree Will a tourist have any trouble getting money from an ATM India because of demonetization? Syntax Error Near Unexpected Token `exit' really good at catching spelling type errors. –davey May 2 '13 at 15:50 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using

asked 2 years ago viewed 7891 times active 7 months ago Get the weekly newsletter! check over here Please visit this page to clear all LQ-related cookies. working now. Ordering a bulky item in the USA Amplifier circuit woe Why are terminal consoles still used? Syntax Error Near Unexpected Token In Shell Script

Difficulties interpreting this complex sentence Unable to complete a task at work. Not the answer you're looking for? I always get messages saying line 5: syntax error near unexpected token 'fi' line 5: 'fi' when I try to execute this script. #!/bin/sh rm /opt/file_name if $? -ne 0 then http://allconverter.net/syntax-error/syntax-error-near-unexpected-token-in.html Apr 13 at 7:50 This question was marked as an exact duplicate of an existing question. 2 if[ is not the same thing as if [ (note the space) –Mat

share|improve this answer edited Jan 22 '14 at 20:36 answered Aug 14 '12 at 8:45 Henk Langeveld 800321 add a comment| up vote 2 down vote Since you're writing for bash, Syntax Error Near Unexpected Token `done' asked 2 years ago viewed 2612 times active 2 years ago Related 2211Check if a directory exists in a shell script760How do I prompt for Yes/No/Cancel input in a Linux shell bash shell shell-scripting share|improve this question asked Jul 27 '12 at 19:12 Evgeniy Yablokov 2411513 3 = is used for string comparison so you should probably be double quoting your

Thank you.

Because the command can be of any length there needs to be a marker to mark the end of the condition part, that is the then keyword, or token, or syntax. The shell executes the command [ with the rest as parameters, including the ] as mandatory last parameter. How to write an effective but very gentle reminder email to supervisor to check the Manuscript? [: Too Many Arguments Joining two lists with relational operators default override of virtual destructor Idiomatic Expression that basically says "What's bad for you is good for me" Unable to understand the details of step-down

Take a look at mywiki.wooledge.org/BashPitfalls in general, and, say, #4 in particular. –cjc Jul 27 '12 at 21:07 add a comment| 2 Answers 2 active oldest votes up vote 0 down and where the line 21 is? –MLSC Feb 10 '14 at 7:54 add a comment| 2 Answers 2 active oldest votes up vote 5 down vote I done\'t see the issue, You are currently viewing LQ as a guest. weblink Also, a space is required between echo and "please enter correct input.".

Registration is quick, simple and absolutely free. Make that assumption explict, so the script will fail when it encounters a host where ethtool does not report the speed in Mb/s.