CS 484 Home Page


Barney Maccabe Last modified: Mon Feb 22 06:43:52 MST 1999

CS 484 Exercise set 1

Due: Friday February 26, 1999 by 5pm

This homework is to be submitted by email, in plain text.

For each of the following exercises, write a shell script or function that solves the problem. In most cases, a shell function is preferable to a shell script. However, shell scripts should be used when the control constructs are moderately complicated.

You should turn in your solution to the problem along with the output form a sample execution. In addition, you should describe any limitations and indicate the platforms that you have used to test your solutions.

Problem 1. Write a shell program (script or function) that will report the 10 largest files in a subtree starting from the directory specified as the first argument to the program.

Problem 2. Write a shell program (script or function) that will report all files with the setuid or setgid bit set in a subtree starting from the directory specified as the first argument to the program.

Problem 3. Write a shell program (script or function) that will move all plain files in the current directory that are older than 6 months to subdirectory called old. (This kind of program might be useful if you are managing a collection of mail folders and you want to clean up the folders that you are no longer using actively.)

Problem 4. Write a shell program (script or function) that will count the number of files of each type (as defined by the file command) in the current directory and all subdirectories. The output should be sorted by number of files of each type.

Problem 5. Write a shell program (script or function) that will change the name of each plain file in the current directory to a name that includes the date the file was last modified.

Problem 6. Write a shell program (script or function) that will find the first available user id (a user id that is not currently being used according to the information in /etc/passwd) greater than the argument it is passed.