Assignment 2: Intro to Shell Scripts

Here is top2.tar with files from Tuesdays meeting and the problems below. Untar with tar xf top2.tar and remove with /bin/rm -rf top2. Here are some questions.
  1. In top2/mv there are a number of files with names in uppercase change the filenames to be in lower case. [Hint tr.]
  2. Write a script safecp which for each arg foo does mv foo foo.orig cp foo.orig foo and then changes foo to be writable. safecp a b ... should safecp each of its parameters. (Why the mv then the copy rather than just cp foo foo.orig? Hint look at the differences with ls -l) The files in top2/mv are not writable.
  3. In unix, the filename foo and FOO are different files. Modify your first script so it does not overwrite an existing file. [Hint test aka if [ ] ; then ...] -- have it abort with error != 0.]
  4. Another useful way to feed data into a shell script is with the read command. For example
    while read email name
    do
    	...
    done < elist 
    
    will run through the file elist line by line, the first `parameter' of the line will be the email address, and everything else will be the parameter name. Write a shell script that will write personalized enote to everyone on elist. [I use /usr/bin/mailx -s "$subject" $email < xx to mail the file xx to $email.] try it with a elist with 'your-email firstname lastname'
  5. Try a slide show of some kind. If you don't have some pictures you can run a script that outputs "plot sin(x+$n.0/10)" piped to gnuplot (you might want to sleep between plots.)