Question: Write a Bash script to back up a list of files with some given extensions. Basically the files are copied into a folder created in

Write a Bash script to back up a list of files with some given extensions. Basically the files are copied into a folder created in the target directory, named the current date. The name is a string obtained from date command, but blanks and : are removed, using tr command. E.g., TueJan22112241EDT2021 is a valid name, obtained using date and tr. Then, all files are archived using tar utility then, the original files (the ones just copied) are removed. The name of the archive should be archive.tar

Synopsis:

backup [-t] target-directory suffix-list...

By default, the current working directory is the target directory. However, when -t option is provided, the files to be copied are located in target-directory.

If target-directory is not a valid directory, then an error message is printed before exiting.

Some sample runs:

Case 1: backup files from current directory

% backup pdf jpg copied pdf files copied jpg files tar file

created ./TueJan22112241EDT2021/archive.tar source files deleted

Case 2: backup files from a target-directory % backup -t /home/users/bigFoot/ pdf

ppt copied pdf files copied ppt files tar file

created ./TueJan22112241EDT2021/archive.tar source files deleted

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!