Do the problems below on one of the CSUG Linux machines, i.e. csug01 through csug06.csuglab.cornell.edu. Email me your solutions (scripts) as separate files, named appropriately, AND turn in a hardcopy of your answers to both problems with your full name and netID, in class or in my mailbox (657 Rhodes) by 5 p.m. on the due date given on the main course page.
Problem 1: How big is my music collection? (musiclib.sh)
Suppose you have a music collection made up of mp3, mp4, and Ogg Vorbis files (shame on you if you use Windows Media Player format!). These files end with .mp3, .mp4, or .ogg extensions. Write a script that counts the number of files of each type that you have in the current directory and the total amount of disk space (kilobytes) the files of each type use, the total number and disk space usage of all files, and then outputs that information to stdout. Example output would be:
You have 10 music files that use 47513K of disk space:Problem 2: Backing up (backup.sh)
Write a script that takes up to 4 arguments: flag, num, basename, and target in that order. The flag argument is optional, and must be -c if given. The script should search for files that are older than num days, starting from the directory given by basename. Any such files that are found should be moved to a directory called target in the user's home directory. Once all of old files have been moved, the target directory should be renamed target.date (where date is the current date in yyyy.mm.dd format), archived using the tar command and gzipped with gzip. If the flag is given as -c, then the files should be copied rather than moved. Your script should check for the following: