Remember: when building scripts, work in steps and test each step before incorporating it in your script.

  1. Create a script that will take a (recursive) copy of files in /etc so that a beginning system administrator can edit files without fear.

  2. Write a script that takes exactly one argument, a directory name. If the number of arguments is more or less than one, print a usage message. If the argument is not a directory, print another message. For the given directory, print the five biggest files and the five files that were most recently modified.

  3. Can you explain why it is so important to put the variables in between double quotes in the example from the section called “Output redirection”?

  4. Write a script similar to the one in the section called “The break built-in”, but think of a way of quitting after the user has executed 3 loops.

  5. Think of a better solution than move -b for the script from the section called “Examples” to prevent overwriting of existing files. For instance, test whether or not a file exists. Don't do unnecessary work!

  6. Rewrite the whichdaemon.sh script from the section called “Boolean operations”, so that it:

    • Prints a list of servers to check, such as Apache, the SSH server, the NTP daemon, a name daemon, a power management daemon, and so on.

    • For each choice the user can make, print some sensible information, like the name of the web server, NTP trace information, and so on.

    • Optionally, build in a possibility for users to check other servers than the ones listed. For such cases, check that at least the given process is running.

    • Review the script from the section called “Calculating an average”. Note how character input other than q is processed. Rebuild this script so that it prints a message if characters are given as input.

  7. Rewrite the testscript from the section called “The shift built-in” to demonstrate the N=0 case and the case where N is not present. Test.