Creating a Simple Unix Shell Script

A script is a plain text file containing commands.

Your scripts should be in a directory in your $PATH

Your scripts need to be "executable"

# This is a comment. Comments are good.
# This is my first shell script.
echo "System Status Report"
echo -n "System uptime and load:" ;  uptime
echo -n "Operating System: " ; sysctl -n kern.ostype
echo -n "OS Version: " ; sysctl -n kern.osrelease
echo -n "OS Revision number: " ; sysctl -n kern.osrevision
echo -n "Hostname: " ; sysctl -n kern.hostname

bytes=`sysctl -n hw.physmem`
megabytes=`expr $bytes / 1024 / 1024`
echo "Physical memory installed (megabytes): $megabytes"


Previous - Opening Files from the Command Line

Next - Take a short break