Home > Syntax Error > Bash Array Syntax Error Unexpected

Bash Array Syntax Error Unexpected

Contents

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 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 Natural construction On THE other hand or on another hand? Is this safe to display MySQL query error in webpage if something went wrong? http://sovidi.com/syntax-error/bash-script-array-syntax-error-unexpected.php

To fix the issue use bash instead of using sh while executing the script, that should not throw any syntax error. That being given, though -- the better way to read a file list from find would be: file_list=( ) while IFS= read -r -d '' filename; do file_list+=( "$filename" ) done Just because you don't use it directly doesn't mean that there aren't any shell scripts on your system that rely on "/bin/sh" to behave like dash rather than bash. So sayeth the Shepherd Meaning of Guns and ghee Should indoor ripened tomatoes be used for sauce?

Bash Syntax Error Unexpected Token

When was this language released? Can Customs make me go back to return my electronic equipment or is it a scam? Are you perhaps running sh yourscript? This is my first time in shell programming so I am unable to fix the issues myself.

printf '%q\n' "${file_list[@]}" would make sense, sure, but as it is your code only prints the first array entry, and that after string-splitting and glob-expanding it (since you don't quote correctly). Meaning of Guns and ghee A simple visual puzzle to die for Train ride from Copenhagen to Malmo A name for a well-informed person who is not believed? Is it possible to check for existence of member template just by identifier? Syntax Error Unexpected Array Php 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

Join them; it only takes a minute: Sign up Why is my array incorrect for my shell script? but then again I added the line but the error is still coming. How to indicate you are going straight? The Woz Monitor How to pluralize "State of the Union" without an additional noun?

Syntax error: unexpected “(”-3Shell script- syntax error: unexpected end of file2Create array in bash with variables as array name0Syntax Error: unexpected end of file — Bash script1“bad array subscript” error when Syntax Error Unexpected In Shell Script On the first one I create an array thus: #!/bin/bash target_array=( "/home/user/direct/filename -p123 -r" ) That works fine. I will edit it –user1357576 Jun 14 '12 at 3:57 1 @user1357576: Post the solution as an answer and mark it accepted, don't edit it into the question. What to tell to a rejected candidate?

Bash Syntax Error Unexpected End Of File

Is the empty set homeomorphic to itself? 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 Bash Syntax Error Unexpected Token I am creating a shell script. Syntax Error Unexpected End Of File Bash Script 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

Powered by vBulletin Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. weblink Adopt A Jet/Book Did Donald Trump call Alicia Machado "Miss Piggy" and "Miss Housekeeping"? 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 If so, the manual use of sh will override the #!/bin/bash shebang. (Also, allow me to strongly echo the advice given by @EtanReisner; reading from find into an array in this Shell Script Array Syntax Error Unexpected

Problem with using pause and onslide in one frame Can Customs make me go back to return my electronic equipment or is it a scam? Why are some programming languages Turing complete but lack some abilities of other languages? 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 http://sovidi.com/syntax-error/bash-array-syntax-error-near-unexpected-token.php 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

Browse other questions tagged arrays bash sh or ask your own question. Bash Function Syntax Error Unexpected 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 Skeletal formula for carbon with two double bonds Will the medium be able to last 100 years?

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

How does Gandalf get informed of Bilbo's 111st birthday party? That will be true if even if the default login shell for that user is bash –Eric Renouf Jan 7 at 15:26 That was the part in which I However, the script isn't running for some reason. –Michael S. Shell Script Array Problem?

yes I did not add #!/bin/bash. Please explain the local library system in London, England How to extrude a face parallel to another? The crontab job to execute the script every minute and store the output in another file is as follows: * * * * * $HOME/script.sh >> $HOME/output.log 2>&1 How to use his comment is here Dennis numbers 2.0 Skeletal formula for carbon with two double bonds Meaning of Guns and ghee How does Gandalf get informed of Bilbo's 111st birthday party?

Is that my syntax is wrong, or my sh shell version too old, or sh shell do not support array command, only bash shell support it ? $ myarray=(a b c) It's a normal, numerically indexed array. –Dennis Williamson Jun 14 '12 at 3:46 @DennisWilliamson Oh Ok. See mywiki.wooledge.org/DontReadLinesWithFor for reasons why. 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

linux shell cron crontab share|improve this question asked Mar 4 '13 at 19:34 vikash 2819 2 Do you have #!/bin/bash at the top of script.sh? –chepner Mar 4 '13 at Registration is quick, simple and absolutely free. Try to execute with "bash