Backup Loop Example

The following example might stimulate some thoughts on the power of the looping constructs learned in this chapter. The example takes the output of a df command, isolates the file system names, places them in the list portion of a for construct and performs a dump command on each one of them. The level of the dump command is based on the day of the week (Sunday is level 0, or full dump day). You most likely will have to tweak this script to make it work on your system, but the ideas are powerful and solid.

The script also does some pattern work to isolate the file system name with no slashes (/home becomes home). But this causes a problem with the root file system, so the script handles the special case of the root file system ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.