Lab Assignment--Shell Scripts


Your task is to create a tcsh shell script that is able to backup all the C program files in your current directory.

The algorithm is as follows:

The following is a shell script that makes backups to a "backup" directory in your home directory: bckup.sh

You might want to take ideas from it, but note that it does not prompt you if you would like to make the directory.

Please include print messages in your script to indicate if the file was not previously in the backup directory or if the file existed before and is just being updated.

Deliverables:

Submit 2 files to URCourses:

  1. code of tcsh shell script
  2. script of the run showing the test cases outlined below

Test Cases captured in a "script":

  1. Start by removing your backup directory (rm -r backup)
  2. Ensure that there are some .c files in the current directory
  3. Show the directory using ls -l
  4. Run the backup script several times as specified below:
  5. Type "NO" to creating a backup directory
  6. Type "n" to creating a backup directory
  7. Type "up" to creating a backup directory
  8. Type "yes" to creating a backup directory
    This should create the directory and copy files
  9. ls -l backup
  10. Remove the directory (rm -r backup)
  11. Type "Yes" to creating a backup directory
  12. Remove the directory
  13. Type "y" to creating a backup directory
  14. Append to all the files and rerun your backup script
    an good way to append is to type: echo "something" >> file.c
  15. Append to one file and rerun your backup script
  16. Touch a few existing files and rerunning the script.
    Depending on your implementation, this might not do anything.
  17. Create a new .c file (using touch) and rerun your backup script

Notes