Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my array incorrect for my shell script?

Tags:

arrays

bash

sh

I have been searching everywhere for an answer to this question. I have an array in my shell script, but when I run it, I get this error: "(" unexpected

What am I doing wrong here:

array=( 1 2 3 4 5 )

I am using Ubuntu 11.10

like image 577
Michael S. Avatar asked Dec 27 '22 09:12

Michael S.


1 Answers

You are running your script with /bin/sh, not /bin/bash. There are no arrays in sh.

choroba@cyan ~$ /bin/sh
$ a=( 1 2 3 )
/bin/sh: Syntax error: "(" unexpected
like image 54
choroba Avatar answered Jan 11 '23 11:01

choroba