Home > Syntax Error > Bash Script Syntax Error Near Unexpected Token

Bash Script Syntax Error Near Unexpected Token

Contents

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 Reading and interpreting error messages is 50% of your job as debugger! GTIN validation Symbolic comparison of recursive functions Are there any 'smart' ejection seats? did you close your if with a fi? Check This Out

A function call is equivalent to a command.

Example 24-1. You may ask yourself why is this mentioned as debugging tip? It is solved with double quote the second parameter like.. [mycom7] # ./ctopo.sh um_test1 "[(1,2),(2,1)]" rc5gd View Public Profile View LQ Blog View Review Entries View HCL Entries Find More It works well, but when I use it in a shell script, I get the following error message: syntax error near unexpected token `(' Here is the script: #!/bin/sh myfile1=toto1.dat myfile1=toto2.dat

Bash Script Syntax Error Near Unexpected Token Done'

Thanks in advance ! If the default colors are not suitable than you can set the environment varialbes script_color linenum_color funcname_color to any of the following colors: ${darkgrey}darkgrey$nc, ${lightgrey}light grey$nc, ${white}white, ${red}red, ${lightred}light red, ${green}green, did you close your { with a }? Browse other questions tagged linux ubuntu bash docker .

Unix & Linux Stack Exchange works best with JavaScript enabled Bash Hackers Wiki Home Search Tools Site Tools Recent Changes Media Manager Sitemap Page Tools Show pagesource Old revisions Backlinks Back You have to save the new name in a variable for later use, because 'date' might give a different timestamp when you rerun 'date'. How to pluralize "State of the Union" without an additional noun? Bash Syntax Error Near Unexpected Token (' Ubuntu Note that ISO-8859-1 is the same as Windows-1252, which isn't particularly endorsed by ANSI as opposed to Unicode.

It doesn't say anything. –Ignacio Vazquez-Abrams Oct 1 '11 at 18:21 1 Edit your old question, please don't post a new one. Bash Syntax Error Near Unexpected Token 1' f2 # Now, it's all right to call "f2", #+ since its definition has been made visible by calling "f1". # Thanks, S.C.

Function declarations Find and eliminate it!

How can I find and eliminate them? Wiki syntax is allowed: Please fill all the letters into the box to prove you're human.

Click Here to receive this Complete Guide absolutely free. Bash Syntax Error Near Unexpected Token Fi' asked 2 years ago viewed 35553 times active 1 month ago Visit Chat Linked 0 bad character showing up in bash script execution 2 Why is a shell script giving syntax And when you ask them what the error message is, they don't even know. share|improve this answer answered Jul 10 '14 at 12:38 Patrick 34.1k680129 Thanks that is it –user77083 Jul 10 '14 at 12:43 add a comment| Your Answer draft saved

Bash Syntax Error Near Unexpected Token 1'

In that case, there's nothing ANSI about it. –Potatoswatter Jan 5 '14 at 4:01 I suspect the OP's issue was encoding though. How did a CR end up in my file? Bash Script Syntax Error Near Unexpected Token Done' See the example for xtrace output from above. Bash If Else Syntax Error Near Unexpected Token Else' This is unlikely to help. –Cfreak Sep 17 '14 at 15:41 the dos2unix package includes the tool "mac2unix" –Max Mar 16 '15 at 10:20 add a comment| up vote

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. his comment is here In your case, the best way is to double-quote the whole second parameter. On THE other hand or on another hand? How to book a flight if my passport doesn't state my gender? Bash Syntax Error Near Unexpected Token Echo'

test is the name of a UNIX®-command, and most likely built into your shell (it's a built-in in Bash) - so you won't be able to run a script with the How to deal with a really persuasive character? Password Home Search Forums Register Forum RulesMan PagesUnix Commands Linux Commands FAQ Members Today's Posts Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK this contact form Any white space is considered a divider in collections (e.g.

Why? Bash Syntax Error Near Unexpected Token Then' Notices Welcome to LinuxQuestions.org, a friendly and active Linux Community. It sounds like the shell was complaining about the ^M carriage return character, not the quote as the OP seemed to indicate. –Potatoswatter Jan 5 '14 at 4:41 | show 1

Only run carriage_return and you'll be prompted for the file to "clean".

chmod 755 $NEWFILE To display a certain line from the outfile, you can use 'grep' or 'awk' for example. ---------- Post updated at 09:06 ---------- Previous update was at 09:03 ---------- foo=$(< inputfile) printf "DEBUG: foo is |%q|\n" "$foo" >&2 # exposes whitespace (such as CRs, see below) and non-printing characters Use shell debug output There are two useful debug outputs for Were slings used for throwing hand grenades? Bash Syntax Error Near Unexpected Token Do' fun () { # A somewhat more complex function.

echo $SHELL –LatinSuD Jul 10 '14 at 12:23 #!/bin/sh myfile1=toto1.dat myfile1=toto2.dat file_out=mytoto_out.dat touch ${file_out} /usr/bin/pr -mts' ' <( /usr/bin/cut -d' ' -s -f1,2,3,4,5,6,7,8,9,10,11 ${myfile1}) <( /usr/bin/cut -d' ' -s Let's see the xtrace output: + '[' bar baz = test ']' And now you see that it's ("bar" and "baz") recognized as two separate words (which you would have realized asked 2 months ago viewed 92 times active 2 months ago Related 14Why did ; after & return an unexpected token error in bash?1“Syntax error near unexpected token '$'\r''” in shell http://gatoisland.com/syntax-error/bash-for-syntax-error-near-unexpected-token.php If you reproduced or fixed the problem, you should mention so.

When taking passengers, what should I do to prepare them? what needs to be changed or manipulated in the above script Last edited by Scott; 02-03-2010 at 02:30 AM.. At the very least, they can give you hints as to where to start debugging. 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

© Copyright 2017 gatoisland.com. All rights reserved.