UNIX/Linux Tools and BASH Basics, computer science homework help

Jan 20th, 2016
Computer Science
Price: $15 USD

Question description

Lab 2: Search and Report


Lab 2 is an opportunity to use a number of UNIX/Linux tools to search subdirectories, report the nature of files found and produce a summary report.


Your script shall be named ~/cs3030/lab2/srpt and be marked executable. Here is how you execute your script:

./srpt PATH

Your script shall inspect the file names of every file and directory in PATH and accumulate a count of each of the following:

  • Every file

  • Every subdirectory (excluding "PATH" itself)

  • Every symbolic link

  • Every file that is 365 days old or older (old files)

  • Every file that is larger than 500,000 bytes (large files)

  • Every graphics file (any file with suffix of .jpg, .gif or .bmp)

  • Every temporary file (any file with a suffix of ".o")

  • Every executable file (any file executable by the user)

  • Total byte count of each file

    Your srpt script shall produce a report in this format in this order: SearchReport host path date

          Execution time nnn
          Directories n,nnn,nnn
          Files n,nnn,nnn
          Sym links n,nnn,nnn
          Old files n,nnn,nnn
          Large files n,nnn,nnn
          Graphics files n,nnn,nnn
          Temporary files n,nnn,nnn
          Executable files n,nnn,nnn
          Total file size n,nnn,nnn

    Your searchreport script should exit with return code zero after producing its report unless the path was not specified on the commandline. If your script is executed without a PATH, issue this usage statement and

1 o f 4

exit with return code 1:

  Usage: srpt path

 Scripting Languages

Lab 2: Search and Report

Here is an example of what your script should produce (text colors are slightly different than PuTTY because I ran this from my Mac).

Additional Requirements

You are free to use whatever tools that are available in order to produce the requested output. Please note the following:

  • You may only make one pass over the files per execution of your script (meaning no multiple file

    system searches). The find command is the best utility to obtains all of the required information in a single execution of find. Search the Internet for examples on how to use find to search and count files of a given name or type and save that information in a temporary file.

  • You may not modify any file or directory in the requested path. If you create any temporary files, do so only in /tmp. I recommend creating a folder in /tmp with your icarus username. At the end of your script, delete all of your temporary files. Be a good computer citizen.

  • Use self-documenting variables to hold the counts

  • Format counts with commas for readability. Look up the printf command, which can output

    numbers with commas.

  • Output the date in the report header as produced by the date utility. Here is an example output from

         Thu Dec 25 07:00:00 MST 2014
  • Use the BASH variable $HOSTNAME to print the hostname in the report header

  • Execution time is calculated from invocation and ends just before printing the summary report

  • Use whitespace and indenting to make your script readable

  • Add comments to your script to document your logic

  • Test your script using the files located in /var/classes/cs3030/lab2/testfiles:

2 o f 4

Scripting Languages

Lab 2: Search and Report

./srpt /var/classes/cs3030/lab2/testfiles• Your script must successfully complete scanning /var/classes/cs3030/lab2/testfiles in

5 seconds or less.

Run cucumber to determine your grade

  tar xvf /var/classes/cs3030/lab2/cuke.tar
  ./cucumber -s


For this lab you will have created folder lab2 and the following executable files: srpt

Tutor Answer

(Top Tutor) Daniel C.
School: Duke University

Studypool has helped 1,244,100 students

Review from our student for this Answer

Jan 20th, 2016
"Excellent work as usual"
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1823 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors