Shell Scripts
There are hundreds (if not thousands) of Web pages devoted to Linux Shell Scripting. So, for more detailed explanations of what I’ve illustrated here, please visit those pages. A few links are provided here:
- http://lowfatlinux.com/linux-drbob.html#INTRO
- http://www.computerhope.com/unix.htm#05
- http://http://ss64.com/bash/
Now onto my tips.
Create a “bin” directory/folder in your home directory to house your Shell Scripts. From a Terminal session type:
mkdir bin
From the same Terminal session, list the contents of your home directory:
ls
You should see the “bin” folder listed there.
Check the PATH:
echo $PATH
Hopefully you find /home/yourserid/bin: somewhere in the display. If not, you will need to preface your Shell Script filename with “./bin/” in order to run it.
Create a test Shell Script using your favorite Text Editor:
#!/usr/bash echo "Hello World from $USER."
Save it as “hw.sh”, then in the Terminal window make it executable:
cd bin chmod 775 hw.sh
Navigate back to your “home” directory:
cd ..
Then run it:
hw.sh
(Remember, if /home/youruserid/bin is not in your System’s PATH, you will need to type ./bin/hw.sh.)