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

Syntax Error Near Unexpected Token 'else'

Contents

Browse other questions tagged shell or ask your own question. For the shell to recognize the then as a token it needs to standing in a line on its own or be separated by a ;. Also thanks for the link. –GleDel Apr 24 '15 at 10:17 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign current community chat Unix & Linux Unix & Linux Meta your communities Sign up or log in to customize your list. his comment is here

Just pass any args needed, i.e. what's the error? –qqibrow Jan 20 '15 at 22:15 sorry new to stack overflow and learning formatting, i edited my comment above –Devin Baize Jan 20 '15 at 22:16 The problem statement, all variables and given/known data: line 37: syntax error near unexpected token 'else' line 37: ' else' the script is made to take 1 or 2 command line Please Try > again!" fi done unix if-statement nested syntax-error nested-loops share|improve this question asked Nov 9 '12 at 16:26 user1801053 92 2 That's really awful code formatting.

Bash Syntax Error Near

if [ $unix_OS == "AIX" ] then echo "executing aix function" function_aix else echo "other function" function_other .... When I run the below block of code if [ $rc -eq 0 ] then passed=`tr ' ' '\n' < $TFILE | grep -c PASSED` error=`tr ' ' '\n' < $TFILE LinuxQuestions.org > Forums > Non-*NIX Forums > Programming [SOLVED] bash: syntax error near unexpected token `else' User Name Remember Me?

Why is bench pressing your bodyweight harder than doing a pushup? lucmove View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by lucmove 05-10-2010, 04:34 AM #2 druuna LQ Veteran Registered: Sep 2003 Posts: The Following User Says Thank You to zaxxon For This Useful Post: Ren_kun(08-19-2011) Remove advertisements Sponsored Links zaxxon View Public Profile Find all posts by zaxxon #5 08-18-2011 Ren_kun Syntax Error Near Unexpected Token If Not the answer you're looking for?

Browse other questions tagged bash shell if-statement or ask your own question. Syntax Error Near Unexpected Token Then' In Unix Thanks in advance. 2. how to find it in future Below is the error ./test.sh: line 5: syntax error near unexpected token `else' ./test.sh: line 5: `else' below is my PATH /u01/app/oracle/product/10.2.0/db_1/bin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/oracle/bin which bash /bin/bash like [ $param == '-h' ]; you need to double quote your variable.

more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Syntax Error Near Unexpected Token Elif' Shell Script Change syntax of macro, to go inside braces Plus and Times, Ones and Nines Is the partition function of non-conformal theories on a torus modular invariant? If you do not put a space after [ the shell will try to execute [whatever as command and fail. Insearch: (University of Technology Sydney), Sydney NSW, Australia, James Hu (web systems), www(dot)insearch.edu.au/default.aspx?ArticleID=430 Note: Without school/professor/course information, you will be banned if you post here!

Syntax Error Near Unexpected Token Then' In Unix

Why is the Vitamin B complex, a "complex"? How can I stun or hold the whole party? Bash Syntax Error Near Remove advertisements Sponsored Links Ren_kun View Public Profile Find all posts by Ren_kun

« Previous Thread | Next Thread » Thread Tools Show Printable Version Email this Page Subscribe to Syntax Error Near Unexpected Token Fi' Shell Script The reason for the spaces after [ is because [ is also not syntax.

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 this content Join our community today! They do not always work the same: Code: $ cat foobar #!/bin/bash for i in $(ls -1a); do if [ "$i" == '.' ] then echo 'one dot' elif [ "$i" Browse other questions tagged shell shell-script oracle-database or ask your own question. Syntax Error Near Unexpected Token Then' In Shell Script

Gallen, Switzerland Posts: 6,504 Thanks: 162 Thanked 533 Times in 466 Posts That window looks like a Windows command window. How do I reassure myself that I am a worthy candidate for a tenure-track position, when department would likely have interviewed me even if I wasn't? Should a country name in a country selection list be the country's local name? http://allconverter.net/syntax-error/syntax-error-near-unexpected-token-in.html Browse other questions tagged bash syntax-error or ask your own question.

What does "put on one's hat" mean? Syntax Error At Line Unexpected more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Gallen, Switzerland Posts: 6,504 Thanks: 162 Thanked 533 Times in 466 Posts This is not Unix/Linux.

default override of virtual destructor Idiomatic Expression that basically says "What's bad for you is good for me" Most useful knowledge from the 30's to understand current state of computers &

asked 4 months ago viewed 55 times active 4 months ago Get the weekly newsletter! How to decrypt .lock files from ransomeware on Windows An expensive jump with GCC 5.4.0 Why would a NES game use an undocumented 1-byte or 2-byte NOP in production? you need to double quote your variable. Syntax Error Near Unexpected Token In Shell Script Please update it to use awk.

Replace the lines as follows : .... You must complete the entire template (not just parts of it). Gallen, Switzerland Posts: 6,504 Thanks: 162 Thanked 533 Times in 466 Posts Do you mind posting that code with marking, copy&paste instead? check over here Is it still safe to drive?