Write a bash script called unpack which can unpack multiple packed files (a.k.a “archives”), and even traverse folders r
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Write a bash script called unpack which can unpack multiple packed files (a.k.a “archives”), and even traverse folders r
Write a bash script called unpack which can unpack multiplepacked files (a.k.a “archives”),and even traverse folders recursively and unpack all archives inthem - regardless of thespecific algorithm that was used when packing them. Following isthe exact synopsis:unpack [-r] [-v] file [file...]Given a list of filenames as input, this script queries each targetfile (parsing the output of thefile command) for the type of compression used on it. Then thescript automatically invokesthe appropriate decompression command, putting files in the samefolder. If files with thesame name already exist, they are overwritten.Unpack should support 4 unpacking options - gunzip, bunzip2, unzip,uncompress.Adding more options should be VERY simple.Note that file names and extensions have no meaning - the only wayto know what methodto use is through the file command!If a target file is not compressed, the script takes no otheraction on that particular file.If the target is a directory then it decompresses all files in itusing same method.Command echos number of archives decompressedCommand returns number of files it did NOT decompressAdditional switches:-v - verbose - echo each file decompressed & warn for each filethat was NOTdecompressed-r - recursive - will traverse contents of folders recursively,performing unpack on each.