Home > Syntax Error > Syntax Error Near Unexpected Token Fi' Mac

Syntax Error Near Unexpected Token Fi' Mac

Contents

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? Not the answer you're looking for? Still I don't like your if expression, there's no point to use test command there. check that your code has Unix line endings (\n) not windows/dos line endings \r\n as the \r is interpeted as an unexpected token. his comment is here

What are the ground and flight requirements for high performance endorsement? Joining two lists with relational operators Hit a curb today, taking a chunk out of the tire and some damage to the rim. Alternatives: if [[ $? -ne 0 ]];then or if ! Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap - Main Menu Linux Forum Android Forum Chrome OS Forum Search LQ

Syntax Error Near Unexpected Token Fi' Mac

Deep theorem with trivial proof split strings and add them as new row Why is the Vitamin B complex, a "complex"? Removing brace from the left of dcases Why do the Avengers have bad radio discipline? So, in your case, sh (or whatever Bourne shell you appear to be using), interprets the quotes as if they're balanced, which results in parts of your script being "quoted" which LinuxQuestions.org > Forums > Linux Forums > Linux - General syntax error near unexpected token `fi' User Name Remember Me?

asked 5 years ago viewed 19323 times active 5 years ago Related 0Bash script throws “syntax error near unexpected token `}'” when run0Why syntax error near unexpected token `fi' is coming5bash: printfs first argument is the format string (in this case, "su"), hence, it will print su. Is it still safe to drive? Syntax Error Near Unexpected Token `then' Disease that requires regular medicine How do I politely decline a research grant?

Browse other questions tagged shell scripting or ask your own question. Syntax Error Near Unexpected Token Fi' Cygwin How to change 'Welcome Page' on the basis of logged in user or group? Learn More © 2016 The Linux Foundation UbuntuCommunityAsk!DeveloperDesignDiscourseHardwareInsightsJujuShopMore ›AppsHelpForumLaunchpadMAASCanonical current community chat Ask Ubuntu Ask Ubuntu Meta your communities Sign up or log in to customize your list. 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

Training Certification Events Webinars CommunityParticipate Q&A Forums Blogs ResourcesNewsletter Distributions Publications Infographics Photos Videos Jobs deatharte October 8, 2010 syntax error near unexpected token `fi' Forums:Command Line/Scripting #!/bin/bash if [[ -e Syntax Error Near Unexpected Token Else value is returned in EDITOR export $answer= is likely to fail (first time) or give unexpected result (next time) use $answer to call editor ( or $answer "$myfile" ), use export That should solve this problem. Secret salts; why do they slow down attacker more than they do me?

Syntax Error Near Unexpected Token Fi' Cygwin

Plus and Times, Ones and Nines How to reward good players, in order to teach other players by example Am I being a "mean" instructor, denying an extension on a take Lagrange multiplier on unit sphere What mechanical effects would the common cold have? Syntax Error Near Unexpected Token Fi' Mac Some environments DO get it wrong in unexpected ways if you don't. Syntax Error Near Unexpected Token Fi Linux e.g:- 062000002015.00"; echo "Example: sh run_billing.sh 062000002015.00"; exit 1 fi if [ $NARGS -eq 2 ] then echo "Run Billing script - pin_bill_day"; pin_virtual_time -m2 $1; pin_bill_day; fi shell scripting share|improve

This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. this content will not do what you (probably) want, here. else .. more hot questions question feed lang-sh about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation Syntax Error Near Unexpected Token For

The following code is correct: if [ $# -eq 1 ] then echo ok fi Also, these brackets are not actually if condition brackets. Why is the Vitamin B complex, a "complex"? 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 weblink Why does Davy Jones not want his heart around him?

fi construct. Syntax Error Near Unexpected Token Elif' Shell Script Can you check with cat -v or simply create a new script and copy/paste the above yourself? Hit a curb today, taking a chunk out of the tire and some damage to the rim.

Bounce off the atmosphere at reentry?

share|improve this answer edited Dec 5 '15 at 6:29 answered Dec 5 '15 at 4:49 type_outcast 1,082212 Alternatively, run the sql query just once (instead of 3 times), capture Bill –Bill Sherwin Mar 24 '10 at 15:38 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook 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 `done' This is explained here You can use arithmetic expressions in if, so you don't have to use [ ] or [[ ]] at all in some cases.

check that your code has Unix line endings (\n) not windows/dos line endings \r\n as the \r is interpeted as an unexpected token. 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. I picked bash out of a hat as the question didn't specify. check over here Resubmitting elsewhere without any key change when a paper is rejected Does using documentation as a developer make me look unprofessional?

If then is in the 1st line, you use ;. Hot Network Questions An expensive jump with GCC 5.4.0 Add a language to a polyglot Why does MIT have a /8 IPv4 block? more hot questions question feed lang-sh about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation If so, it probably contains DOS line endings, which can confuse the bash parser.

How do I politely decline a research grant? Not the answer you're looking for? 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. nx5000 View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by nx5000 04-19-2007, 07:28 AM #7 dasy2k1 Member Registered: Oct 2005 Location: 127.0.0.1

If any one can help identify what is wrong with the if statement I'd really appreciate it. asked 6 years ago viewed 5152 times active 5 years ago Related 0Redhat Shell Script If Statement fails with odd syntax error-1Please help me understand useradd example's syntax0Apache print syntax errors Is resset.log a typo, or do you really have three different logs? I just realized that my encoding in Notepad++ had somehow gotten changed to "Windows/Dos" instead of "UNIX".

I runned it online on http://www.compileonline.com/execute_bash_online.php it is working well but not on my system(Centos 6.2). I could have mentioned that in my answer, though. –type_outcast Dec 5 '15 at 5:41 I think #!/bin/sh would be preferred in this case. Joining two lists with relational operators How many times do you need to beat mom and Satan etc to 100% the game? If you do something like od -c run_billing.sh, you'll see them there as \r characters as per my test script (the ^M characters are CR): if [[ 1 -eq 1 ]]^M

Hit a curb today, taking a chunk out of the tire and some damage to the rim. Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. This is my code: #!/bin/bash echo "start\n" for f in *.jpg do fname=$(basename "$f") echo "fname is $fname\n" fname="${filename%.*}" echo "fname is $fname\n" if[$((fname % 2)) -eq 1 ] then echo Unix & Linux Stack Exchange works best with JavaScript enabled current community chat Unix & Linux Unix & Linux Meta your communities Sign up or log in to customize your list.

I went and used the menu to switch it back, and now it works like a charm! –DarthCaniac May 9 '12 at 20:03 Mind if I point out that The second is equivalent to your if statement.