[Solved] CSC4103 Assignment3-Shell Programming

$25

File Name: CSC4103_Assignment3-Shell_Programming.zip
File Size: 348.54 KB

SKU: [Solved] CSC4103 Assignment3-Shell Programming Category: Tag:
5/5 - (1 vote)

To learn the use of Bash shell programming.

Background

The shell scripting is a powerful tool to execute a batch of Unix commands for completing a complicated task. In the class, we have learned the basics of Bash Shell programming. This project is a programming practice to use shell for a simple file processing.

Programming Task

Download the tar ball at the link http://www.csc.lsu.edu/~fchen/class/csc4103-sp19/ assignments/lfw.tgz, which is a subset of an image database from UMass [1]. Download and untar the package, which creates a directory. This directory contains a set of subdirectories, each of which contains one or more images. This directory of files will be used as your test input. You need to write a shell script (batch_tar.sh) to process the files by the guideline below.

  1. Your script should provide help information. Typing command %./batch_tar.sh help should print help info to explain how to use the script.
  1. The shell script sh should accept two parameters to allow users to specify the input directory of the files and the output directory. An example command:

%./batch_tar.sh <input_dir> <output_dir>

  1. The output directory should be created by your script and should have the same directory structure as the input directory.
  1. For each file in the input directory, the script should produce a compressed tar file with proper naming in the corresponding output path. For example, for image jpg should be named as foo.tgz. The file should be placed in the same subdirectory in the output directory, just like the original image.

For example, if the original file is input_dir/foo/test.jpg, the output file should be output_dir/foo/test.tgz.

  1. After a file has been processed, print a line of processing info to show (1) the name of the original file, (2) the size of the original file, (3) the name of the tar file, (4) the size of the tar file.
  1. After all images have been processed, print summary info to show (1) the total number of original files being processed, (2) the total size of original files, (3) the total number of the tar files, and (4) the total size of the tar files.
  1. Your script must use functions to organize your code.

Additional Hints

  • Use the following command to download and unzip the tar ball.

$ wget http://www.csc.lsu.edu/~fchen/class/csc4103-sp19/assignments/lfw.tgz

$ tar -zxvf lfw.tgz

  • Use the following command to compress a file to a tar ball.

$ tar zcvf <tar file> <original file>

For example, we can use the command $ tar zcvf foo.tgz foo.jpg to compress the file foo.jpg.

  • Use the following command to extract the first half of the file name.

$ echo <file name> | cut -d . -f 1

For example, the command % echo foo.jpg | cut -d . -f 1 will output foo.

  • Use the following command to get the file size in bytes.

$ wc -c <file name> | awk {print $1;}

  • Use man to get extra help info about the commands.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSC4103 Assignment3-Shell Programming
$25