I am writing this simple bash script as follows.
#!/bin/bash
array=( /home/abc/Downloads/something.bat /home/abc/Downloads/smb.conf )
echo ${array[@]}
I expected it to print all the names of the files in the array. But I get this error instead:
test.sh: 3: Syntax error: "(" unexpected
If I change the declaration of array to
array = {/home/abc/Downloads/something.bat /home/abc/Downloads/smb.conf}
this error goes away but I still have new errors
test.sh: 3: array: not found
test.sh: 4: Bad substitution
How can I resolve this issue? This is my first time in shell programming so I am unable to fix the issues myself.
RESOLVED:
I was executing it as sh test.sh but I forgot I had to execute it as bash test.sh