Question: Write a Bash script to back up a list of files with some given extensions. The target files are first copied into a new folder,

 Write a Bash script to back up a list of files

Write a Bash script to back up a list of files with some given extensions. The target files are first copied into a new folder, created in the target directory and named with the date of the back-up day. The folder name is a string obtained from date command, but blanks and special characters are removed using tr command. E.g. January182020 and January 252020 are valid names obtained using date (with the appropriate options) and tr. Then, all these files are archived using tar utility and finally, the original files (the ones just copied) are removed. The name of the archive should be backup.tar. Synopsis: backup [-t] target-directory suffix-list... By default, the current working directory is also the target directory. However, when the option -t is provided, the files to be copied are located in target-directory. If target-directory is not valid, then an error message is printed before exiting. Sample runs: Case 1: target files are in current directory % backup doc jpg copied doc files to ./January192020 copied jpg files to ./January192020 tar file created ./January192020/backup.tar source files deleted Case 2: target files in a target-directory % backup-t /home/users/bigFoot/ pdf ppt copied pdf files to ./January202020 copied ppt files to ./January202020 tar file created ./January202020/backup.tar source files deleted Hint: you can move all your arguments ($*) into an array variable, then use an index variable to move in the array, depending on the options

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!