This assignment will give you practice in writing shell scripts. Do your own work. See policies to avoid losing hundreds of points for a silly mistake.

The Task

Here are some simple scripts to get some practice. All the scripts here are very short. Under a dozen lines and under 200 chars... (not counting comments) way under. If you find you are outside that limit then something has gone terribly wrong. I won't even grade any script over the above size limit.

Assume the shell you use for the scripts is the Bourne shell at /bin/sh. Read each problem completely so you will get every detail correct. Details count.

  • hi ( 20 pts):

    This command prints Howdy there!. That's it. Be sure to get the printed string correct.

  • ee ( 30 pts):
    ee {filename}

    This command takes a filename. It will remember in the file .ee-lastfile-edited the name of the file given and then go edit it. It invokes the editor given in the variable $EDITOR.

  • el ( 30 pts):

    This command ignores any arguments given. It first checks to see if there is a file named .ee-lastfile-edited and that it is not empty. If that is the case then it opens the named file in the editor $EDITOR. If the file named .ee-lastfile-edited does not exist or is empty then it will edit with $EDITOR the file that was most recently modified (use the ls command to find this information). It will remember that file name in .ee-lastfile-edited.

  • backup ( 30 pts):
    backup files

    The date command: date +'%h-%d-%Y' will print out the date in a nice format with no blanks in it. The backup command will create a directory whose name is the string returned by the date command above preceded by the string: "Backup-". For example for Feb 2, 2017 it would be named: Backup-Feb-2-2017. It will not issue an error if it already exists. It will then copy all of the files listed in the argument list into that directory. Backup copies the files even if the files are already in the directory for that date.

  • star ( 30 pts):
    star tarfile files

    star stands for safe tar. It takes the first argument as the base name for the tar file. It will save all the remaining files in the tarfile named the first argument followed by .tar unless that file already exists. If the target tar file already exists it will issue an error:

    ERROR(star): target tar file filename already exists

    with filename replaced by the name of the target tar file. A return code of 1 is returned on error otherwise 0. It will use the tar command with the cvf options.


    star mytarfile ant bat cat dog
    will do the command: tar cvf mytarfile.tar ant bat cat dog. Doing the command again:
    star mytarfile ant bat cat dog
    Will issue the error ERROR(star): target tar file mytarfile.tar already exists
    star mytarfile.tar ant bat cat dog
    will do the command: tar cvf mytarfile.tar.tar ant bat cat dog.


Homework will be submitted as an uncompressed tar file (see the tar command in the Basic Unix Commands handout) to the class BBLearn page.

Have fun.