Answered step by step
Verified Expert Solution
Question
1 Approved Answer
show me the output Write a Bash script to back up a list of files with some given extensions. The target files are first copied
show me the output
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., January 182020 and January252020 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 ./January 202020 copied ppt files to ./January 202020 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. 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., January 182020 and January252020 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 ./January 202020 copied ppt files to ./January 202020 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 optionsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started