Shell scripts include commands that would normally go on a command line in a terminal window. They are very useful for frequently used commands. The first line includes “#!” and the name of the program that will accept the commands. This is followed by the sequence of commands. For example, here is a script to start 3DVisualizer on Dawn's laptop with the header file in the folder ~/data:
#! /bin/bash cd ~/data 3DVisualizer -class ImageStack DK_2_06.shdr
It is saved as a text file called 3dDK20. The shell script can be turned into an executable file by changing the permissions for the script file. To see the permissions, make sure you are in the directory with the script ('cd <path and directory>') and type:
returns: -rw-r–r–@ 1 sumner staff 68 Jun 4 14:52 3dDK20
chmod u+x <file name> ls -l
returns: -rwxr–r–@ 1 sumner staff 68 Jun 4 14:52 3dDK20
To run the script, make sure you are in the directory of the script and type:
The './' means that the script to execute is in the directory your terminal is currently located in.
That's all there is to it!