Shell Programming Examples: Case Studies
10/30/04
Also illustrates Usage error,
Errors going to standard error,
Printf to output in nice columns,
set to access fields in a line,
bc to calculate with fractions.
Also illustrates how to use unique temp files so multiple
users can run the script simultaneously,
How to make sure the temp files are deleted when the program is done
or if the user aborts it (via INTR or QUIT),
How to use sed to add chars to the start of the line,
Using comm to compare two sorted lists,
Also illustrates that trap variables are evaluated when trap code
is defined so we make trap call a subroutine so that variables
will be evaluated when the subroutine is invoked. We use this
technique to return a valid zero vs. non-zero exit status.
Also illustrates how to check if no characters were input,
check if input exceeds 30 characters in length,
check if input lacks both first and last name,
exit if too many wrong answers.
Also illustrates how to redirect stdin to a while loop,
how to use "set" and "for" to access each word in the line,
Also illustrates how echo can output multiple lines,
How to use a shell function/subroutine,
How to backup the system using cpio,
How to save and report the status of the cpio backup,
How to save start/end time and errors in a log,
How to force output to the screen (/dev/tty) even if
stdout is redirected away from the screen.