Activity - shell script
Read backup.sh.
Let’s modify the script to take file names as arguments, check whether a backup has been made for each file. If so, then run diff
command to compare the file and its backup; if not, then create a backup for the file and add ‘.bak’ to the original file name.
Now, make a copy of the script for yourself,
cp /thayerfs/courses/22spring/cosc050/workspace/backup.sh .
or, to work on your laptop,
scp netid@plank.thayer.dartmouth.edu:/thayerfs/courses/22spring/cosc050/workspace/backup.sh .
Practicing defensive programming, we should make our script able to handle various input arguments gracefully. Thus, our script should check each given file name and see if the file exists first before checking its backup.