The file name of the shell script usually ends in. sh, or in other formats, such as. txt or even without a suffix. The #!/bin/bash of the first line of the script represents the parser that specifies when the script executes.
#!/bin/bash# file name: test.sh# In addition to the first line of the well number represents the parser executed by the script # The rest of the notation indicates the comment echo "aaaaaaaaaaaaaaa" echo "bbbbbbbbbbbbbbbb" #echo " CCCCCCCCCCCCCCC "echo" DDDDDDDDDDDDDDDDD "
The newly created shell script does not have execute permissions, can be run through the Bash command, or you can change the permissions of the script after you use the./test.sh to execute. Note./indicates the current path, do not use test.sh directly to try to execute the script, if not add the preceding./, the interpreter will go to the/bin directory to find test.sh instead of looking for test.sh in the current directory. And then it goes wrong.
When you use the Bash command to execute a shell script, you do not need to specify the parser in the script, and you do not need the script to have Execute permissions
When using./test.sh to execute a shell script, you need to specify the parser in the script, and you need the script to have Execute permissions
Shell Script First Lesson