Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a script shellsearch with options that displays user information based on the users shell by searching an /etc/passwd-like file. The command will allow these

Write a script shellsearch with options that displays user information based on the users shell by searching an /etc/passwd-like file. The command will allow these options (explained in more detail in the instructions below):

Option

Description

-a

Display users with all shells. Cannot be used with -s.

-f FILE

Search in FILE. FILE must be formatted like /etc/passwd.

-h

Display usage information.

-s SHELL

Display users with SHELL shell. SHELL must be in /etc/shells. Cannot be used with -a.

You should reference the supplied sample output and make your formatting and wording match. For any wording you cannot see in the sample, follow the general style of the sample.

Your script should do the following:

  • Use getopts and allow for the following options to be used:
    • -a: Display users with any shell. Cannot be used with -s. If used with -s, program should display an error and exit with status 1.
      • Sample use: ./shellsearch -a
    • -f FILE: Search in FILE. FILE must be formatted like /etc/passwd. If FILE is not a file or not readable display an error and exit with status 1.
      • Sample use: ./shellsearch -f /etc/passwd
    • -h: Display usage information for all options then exit with status 0.
      • Sample use: ./shellsearch -h
    • -s SHELL: Display users with SHELL Shell specified must be in /etc/shells, otherwise display an error and exit with status 1 (you could accomplish this with a grep). Cannot be used with -a. If used with -a, should display an error and exit with status 1.
      • Sample use: ./shellsearch -s /sbin/nologin
    • If the script is run with no options, display the usage information (same as -h).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Entrepreneurial Finance

Authors: Steven Rogers

4th Edition

1260461440, 978-1260461442

More Books

Students also viewed these Finance questions

Question

What is the problem asking me?

Answered: 1 week ago