COMP-8567 Assignment 05 

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (4 votes)

Read the Linux manual for commands find and tar and write a Bash script, call it organize, to collect and copy files, from a target directory hierarchy, with specific extensions, into a number of tar files, to be saved in a destination directory. Synopsis: organize [-t tarDir] [-o orgDir] organize should use command find to visit each file in the hierarchy, defined by the root directory tarDir, and if their extensions are in extensionList, the files are copied to the directory orgDir, where each group of files with the same extension are tared to a single file called, extensionName.tar (e.g. doc.tar) then deleted (only tar files are to remain). Additional Rules: When orgDir is missing, then directory orgDir should be created in current directory (PWD) and used for tar files. When tarDir is missing, then current directory (PWD) should be used as target directory. The script should check if orgDir exists (when provided) and if it has write permission. Otherwise, your script should exit with an error message. • Since command find might find multiple files with the exact same name and extension in different subdirectories of the hierarchy, your script should first check if the same name already exists in orgDir, 2 in which case you should add 1 or 2, etc. to the destination file name resulting from the copy. Below are some sample runs: Example 1: $ organize -o ∼/save txt doc //Note: -t tarDir is not listed, and therefore the PWD should be assumeD as tarDir Searches all files whose extensions are either txt or doc in the whole directory hierarchy (root is current directory, that is, .), creates ∼/save if it does not exist already, then copies all these files to ∼/save (make sure same-name files are copied properly). Then, all txt filesare tared as txt.tar and all doc files are tared as doc.tar. Example 2: $ organize pdf doc txt //Both -t tatDir and -o orgDir are not listed Searches all files whose extensions are either pdf, doc or txt in the directory hierarchy (root is .), creates orgDir then copies all these files to it and tar them accordingly. Submission: Submit a single file organize.sh