Starting from:

$10

Bash script

Write a Bash script to compress a list of files with some given extensions. The
compression could be done with any Unix compress utilities, such as gzip, bzip2, etc.
Synopsis:
backup [-d] target-directory suffix-list...
When the -d option is provided, all the compressed files will be saved into a target
directory. However, if the given directory name is not valid or is an existing regular file, then an error message will be given and no compression should be performed.
Some sample runs:
Case 1: Compress files only
% backup pdf jpg
compressed 2 pdf file(s)
compressed 1 jpg file(s)
Case 2: Compress files but given directory not valid
% backup -d test pdf doc
compressed 2 pdf file(s)
compressed 3 doc file(s)
Error: test is not a valid directory name.
Case 3: Compress and save
% backup -d Jan30-2006 pdf ppt
compressed 2 pdf file(s)
compressed 1 ppt file(s)
Saved in Jan30-2006

More products