Homework 3- Shell Scripting
This homework is due Monday, 13 March 2000.
This is a 40 point homework. Point values for each question are indicated in parentheses after the question. There are more points possible than the 40 I will grade. Here’s how things break down:
· There are four questions, worth 20, 15, 10 and 5 points each (total of 50 points).
· A question will be given full credit if it does what it’s supposed to do, even if it doesn’t detect errors or make the output look “pretty.”
· Each of the four questions has a possible extra credit of 1% on your final grade if you do “full” error checking in addition to solving the problem.
· If you answer all four questions correctly, you will be given an extra credit of 1% on your final grade.
Social Security Number:
1. Write a script called trash that acts like the Microsoft Windows Recycle Bin by moving a file to the “Trash Bin.” When called with a file as an argument it should move that file to the directory $HOME/.trash instead of actually deleting it. You may need to create the $HOME/.trash directory before running the script (or as part of the extra credit handle the possibility that the directory doesn’t exist when trash is called). (20 points)
2. Write a supplemental script to trash called digtrash that will show the contents of the “Trash Bin.” When called without a file as an argument it should list all the files in the directory $HOME/.trash. When called with a file as an argument it should report whether or not that file is in the directory $HOME/.trash. If the argument file is in the directory $HOME/.trash, the script should list the file as it exists in the $HOME/.trash directory. (10 points)
3. Write another supplemental script to trash called pulltrash that will ‘undelete’ a file from the “Trash Bin.” When called with a file as an argument it should move that file from the directory $HOME/.trash to the current directory. (15 points)
4. Write a final supplemental script to trash called emptytrash that will remove all files from the “Trash Bin.” When called it should remove all files in the $HOME/.trash directory. (5 points)