Home > Syntax Error > Bash Array Syntax Error Unexpected

Bash Array Syntax Error Unexpected


munkyeetrMay 15th, 2007, 02:41 PMokay, it now works when I run it using: bash ...which makes sense (now) because my link to sh points to the dash shell. This is an interesting problem, so I did a little experimentation: From a "bash" shell (which is my default), the script works correctly if invoked as "./test", or "bash ./test", but One possible explanation would be if you had a space character in between the equal sign and the open parenthesis, in which case you'd get the following: [email protected]:~/stuff$ ./test ./test: line When taking passengers, what should I do to prepare them? http://gatoisland.com/syntax-error/bash-array-syntax-error-unexpected-expecting.php

Why are some programming languages Turing complete but lack some abilities of other languages? BUT the same commands I put in test.sh and execute, they throw the error..Would you know why? –user1357576 Jun 14 '12 at 3:34 @user1357576 From your comment above, it See mywiki.wooledge.org/DontReadLinesWithFor for reasons why. asked 2 years ago viewed 3927 times active 9 months ago Linked 2 Syntax error: “(” unexpected (expecting “done”) 0 Error with simple shell script Related 18Bash array: Unexpected Syntax error34Bash

Bash Syntax Error Unexpected Token

The sh shell has no syntax to create arrays, but Bash has the syntax you used. something like: Code: /bin/sh for i in `seq 1 5`; do array$i=$i done won't work. Don't use them before or after the equal sign. Find More Posts by konsolebox View Blog 04-04-2012, 07:36 AM #5 expert_vision LQ Newbie Registered: Mar 2011 Posts: 13 Rep: Quote: Originally Posted by konsolebox or you can use

[email protected]:~$ array =(a b) bash: syntax error near unexpected token `(' [email protected]:~$ array= (a b) bash: syntax error near unexpected token `(' [email protected]:~$ array = (a b) bash: syntax error near sh is not guaranteed to be bash in some environments. Meaning of "soul-sapping" Can a creature benefit from differently typed speed bonuses all named fast movement? Syntax Error Unexpected Array Php I will stick to using ./ from now on.

Browse other questions tagged bash or ask your own question. Bash Syntax Error Unexpected End Of File Join them; it only takes a minute: Sign up I am getting error “array.sh: 3: array.sh: Syntax error: ”(“ unexpected” up vote 3 down vote favorite 2 I have written the Is this safe to display MySQL query error in webpage if something went wrong? What are the canonical white spaces?

I know the script works, so it must be some kind of quirk with something else. –Michael S. Syntax Error Unexpected In Shell Script asked 1 year ago viewed 219 times active 1 year ago Related 2882Can a Bash script tell which directory it is stored in?669How do I iterate over a range of numbers Password Protected Wifi, page without HTTPS - why the data is send in clear text? If I type it into the terminal directly it is fine??

Bash Syntax Error Unexpected End Of File

My script is failing to copy the path of each script into the array. Natural construction Religious supervisor wants to thank god in the acknowledgements Activate Hearthstone season chest cards? Bash Syntax Error Unexpected Token Related By Sandeep • Posted in bash script, Linux, Shell Scripting 8 Post navigation ← Grep tab inLinux Bash/Shell Script Arrays → 8 comments on “Shell script arrays Syntax error: "("unexpected” Syntax Error Unexpected End Of File Bash Script edit: In case it helps in reproduction or clues, I'm running Ubuntu 12.04, with GNU bash, version 4.2.25(1)-release (i686-pc-linux-gnu) bash share|improve this question edited Oct 13 '14 at 21:02 Charles Duffy

share|improve this answer edited Aug 9 '14 at 20:50 answered Aug 9 '14 at 20:23 Keith Thompson 145k19190339 add a comment| up vote 1 down vote Instead of using sh to weblink On Debian, sh is usually dash which has no array support (a[index]=x won't work). –Stéphane Chazelas Jan 7 at 15:38 add a comment| up vote 0 down vote Running ./scriptname.sh will How to deal with a very weak student? Main Menu LQ Calendar LQ Rules LQ Sitemap Site FAQ View New Posts View Latest Posts Zero Reply Threads LQ Wiki Most Wanted Jeremy's Blog Report LQ Bug Syndicate Latest Shell Script Array Syntax Error Unexpected

Ash) and be the case that that other interpreter does not support arrays as Bash does. 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 Reap the rewards of your knowledge. –JonRed Oct 13 '14 at 20:06 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted This is precisely the http://gatoisland.com/syntax-error/bash-array-syntax-error-near-unexpected-token.php I hope this helps.

If it is Linux Related and doesn't seem to fit in any other forum then this is the place. Bash Function Syntax Error Unexpected That's fixed now. –Charles Duffy Oct 13 '14 at 21:00 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up What to tell to a rejected candidate?

I strongly suspect you did something else that fixed the problem. –Keith Thompson Aug 9 '14 at 20:15 add a comment| Your Answer draft saved draft discarded Sign up or

Simpler to just run "./test", which works correctly regardless of your default shell, and only invokes an extra copy of "bash" if one is required. Also, don't edit the title to resolve it, the website will mark the question as solved when you accept an answer. –Daenyth Jun 14 '12 at 4:01 add a comment| 3 See if your system has dos2unix then use it like dos2unix myScript.sh Also, as several people have commented on it, please edit your original question to eliminate the spaces around your Shell Script Array Why would this appear?3syntax error near unexpected token `('1syntax error near unexpected token `if'0shell script syntax error: redirection unexpected during done command4syntax error near unexpected token `echo'8syntax error near unexpected token

RESOLVED: I was executing it as sh test.sh but I forgot I had to execute it as bash test.sh arrays bash shell syntax share|improve this question edited Jun 14 '12 at cheers –IGGt Jan 7 at 15:24 That's not necessarily, but there must be coordination between #!/bin/sh and sh script.sh (or #!/bin/bash and bash script.sh) –Konstantin Morenko Jan 7 at That by itself should not have any effect. (And /bin/bash is the default login shell on Ubuntu anyway; had you changed it to something else previously?) What must have happened is http://gatoisland.com/syntax-error/bash-script-array-syntax-error-unexpected.php Adopt A Jet/Book Did Donald Trump call Alicia Machado "Miss Piggy" and "Miss Housekeeping"?

Send to Email Address Your Name Your Email Address Cancel Post was not sent - check your email addresses! alinas View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by alinas 04-05-2012, 10:45 AM #9 uhelp Member Registered: Nov 2011 Location: Germany,

© Copyright 2017 gatoisland.com. All rights reserved.