Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This project involves writing several bash scripts that take parameters and do a task. They each require input checking and validation. A.Write a script named

    • This project involves writing several bash scripts that take parameters and do a task. They each require input checking and validation.

      A.Write a script named fileChecker.sh that will do the following:

      take a name of a directory as a parameter and a string (make sure to verify that the first parameter is a directory, output an error message and terminate, same if more than two parameters is given. The second parameter can be anything).

      loop through all files in this directory and display their names. However, if one of the names exactly matches the second parameter, output INVALID FILE EXISTS and terminate the script.

      For all of the files in that directory, also display only those files that contain (but do not exactly match) the second input string. Do so with the following message WARNING: Danger detected in name X, where X is replaced with the actual name of the file that contained our second argument.

      B.Write a script named fileInfo.sh to give a user information about all arguments given to the script. Note that it could take in any number of command line arguments. Your script should do the following, for each argument:

      Inform the user if the argument is a regular file, a directory or a special file.

      If it does not exist as a file or directory, check to see if it is currently a user logged into the system. If so, inform the user.

      Perform each of the above operations as a function, that is pass the relevant argument to a function and have that particular function do the task.

      Make calls to the function using a loop on the list of files specified as positional parameters.

      If the user does not specify any parameter, print the “usage” line and exit with non-zero status. When I say a usage line, I mean an error message that indicates exactly the type of data that the script is supposed to take in.

      student submitted image, transcription available below 

         

 

      

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here are the Bash scripts for A fileCheckersh and B fileInfosh fulfilling the requirements mentioned in the prompt A fileCheckersh Bash binbash Functi... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial and Managerial Accounting

Authors: Jonathan E. Duchac, James M. Reeve, Carl S. Warren

11th Edition

9780538480901, 9781111525774, 538480890, 538480904, 1111525773, 978-0538480895

More Books

Students also viewed these Accounting questions

Question

11.40. (t) = -6e

Answered: 1 week ago