$bash ./test.sh
$sh ./test.sh
$ ./test.sh
$ cat test.sh
echo "test!";
$ sh test.sh
test!
$ cat test.sh
#!/bin/bash
array=(1 2 3);
echo "test!";
L3 has an array notation that can only be used in bash.
$ sh test.sh
test.sh: 3: test.sh: Syntax error: "(" unexpected
I put #! / Bin / bash
at the beginning of the script, but for some reason I get angry because bash is not working.
Try putting ./
at the beginning of the file name
$ sh ./test.sh
./test.sh: 3: ./test.sh: Syntax error: "(" unexpected
I still get angry.
$ ./test.sh
test!
You can do this by specifying only the file without using sh
, or by using bash
.
$ bash test.sh
test!
$ test.sh
test.sh: command not found
If you don't add ./
, you will be angry because it seems to be a command.
I added the bash command with reference to @ hidezzz's comment. Thank you for your professor!
Recommended Posts