CSE314 Assignment 5- Shell Script Solved

30.00 $

Category:

Description

5/5 - (1 vote)

One of your friends from another department is really messy when it comes to organizing his computer. Currently, he is struggling with a lot of files. He wants to organize the files based on the type of files. So he is asking for your help.

Input:

He will give you the name of the root directory (with lots of files and sub-directories) and another input file.
In the input file, he will mention the type of files he wants to ignore, each in separate lines.

Tasks:

In this assignment, you have to do the following

  1. Take the working directory name (optional) and input file name as a command-line

    argument

  2. If the user does not provide any working directory name, consider your script is lying in

    the root working directory

  3. If the user does not provide any input file name, show him a usage message (i.e. how to

    use this script of yours)

  4. Read the types of files to ignore from the input file (if the input file does not exist,

    prompt the user to give a valid input file name)

  5. Recursively, from the root working directory and all of its sub-directories, collect the files

    whose types are not in the input file.

  6. Gather all the required files in a separate output directory (created by you outside the root

    working directory). For each type of file, create a subdirectory in the output directory. The name should be the type of file. You can determine the type of the file from its extension. If there is no extension, move it to a subdirectory named “others”. You can ignore the duplicate files (files with identical names).

  7. For each type of file, you also need to create a text file in the subdirectory of that type. In this file, you need to add the relative paths(path from the root working directory) of all the files of that type. Do this for the other types of files as well.
  8. Create a .csv file containing two columns, namely file type, and number of files. Fill this out after organizing all the files.

Output:

You need to give two(2) outputs

  • ●  An output directory where all the files are organized as mentioned above
  • ●  A .csv file

    Help:

    You may find the cut, sed, and find commands useful. Have a look into shell parameter expansion

    If you need help working with CSV files using the LINUX command: https://bconnelly.net/working-with-csvs-on-the-command-line/

    Restrictions:

    Please DO NOT COPY solutions from anywhere (your friends, seniors, internet, etc.). Any form of plagiarism (irrespective of source or destination), will result in getting -100% marks in the offline. You have to protect your code.

    Disclaimer:

    The sample input and output files are simply for clarifying the formats. No guarantee is given that the outputs will be the same for the provided input.

  • Offline_SS-009ldh.zip