Showing posts with label Bash. Show all posts
Showing posts with label Bash. Show all posts

Thursday, April 17, 2014

Resolving Bash Error: syntax error near unexpected token `(' declare -a

Writing a bash script, I got an error when trying to run it :

syntax error near unexpected token `(' declare -a

My array was declared was :
declare -a persons = ('person1' 'person2')

Even though my code looks correct and nice ;) ,  Unix don't accept it. I was removing the quotes.... but nothing worked.

And finally I find the solution: In fact we shouldn't put any space between = and (.

declare -a persons=('person1' 'person2') 

Articles les plus consultés