Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 options

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions