I am getting error “array.sh: 3: array.sh: Syntax error: ”(“ unexpected”

前端 未结 3 1705
感动是毒
感动是毒 2020-11-28 13:19

I have written the following code:

#!/bin/bash
#Simple array
array=(1 2 3 4 5)

echo ${array[*]}

And I am getting error: array.sh: 3: a

3条回答
  •  抹茶落季
    2020-11-28 13:36

    I solved the problem miraculously. In order to solve the issue, I found a link where it was described to be gone by using the following code. After executing them, the issue got resolved.

    chsh -s /bin/bash adhikarisubir
    
    grep ^adhikarisubir /etc/passwd
    

    FYI, "adhikarisubir" is my username.

    After executing these commands, bash array.sh produced the desired result.

提交回复
热议问题