Shell scripts (like Bash) are just text files. You will have to set the permissions to give yourself execute access (Use the chmod command). Also when you execute your script be sure that the script is store in a directory on your search list or if the script is in you current directory use the ./ path before the scriptname (or add the ./ directory to your search list).
True. What you are doing then is spawning a new process ("bash"), just to run a script. And sometime there are good reasons for doing so. In the olden days, it would have seemed unnecessary overhead. Fast computers today -- poof!
About "format". Generally shell scripts start with line
The #! is called shebang (for some reason), and it means to kernel that
- the file is a script
- the script is interpreted by program that is after the shebang
You run the script either
- by giving its name: name-of-the-script
- by giving its path : /dir/subdir/name-of-the-script
- by giving source command to your current shell (either . or source, depending on the shell you are using)
The first case works only if the script is on place named in $PATH environment file. The first and second case work only if you have set the execution bit on the file (using command "chmod u+x the-file-name").
But, if you meant the extension by the shell script, there is no restriction, but normally the script is named either without extension ("myfinescript") or with extension that reminds that it is shell script ("myanotherscript.sh")