Skip to Content

groupname assignment

I was wondering if someone could please show me how to do this assignment which I am having trouble figuring out. And possibly explain it as well.

Thanks a bunch

Write a shell script call groupname that does the following:

  1. Insert a reference to the Bourne shell as the command interpreter of this shell script.
  2. Add the appropriate comments
  3. Test that exactly one command line argrument is enter from the command line. If not, display the usage message and stop the script and set the status to 1. If exactly one is entered, continue processing.
  4. The argument entered on the command line is your account name (ie firstnamelastname)
  5. Using the command line arguement search the password file for a match.
  6. Using the line that matched, get the 4th field and search the /etc/group file for a match.
  7. Display the only the group name to standard out.
  8. Cut and Paste you program in the space below also with a session of you executing your program with the examples provided.

For Example,

$ groupname swiersma

will output to standout staff


$ groupname

Usage: groupname account_name


$ groupname swiersma jsmith

Usage: groupname account_name

linuxawy's picture

what part exactly you need

what part exactly you need help in?

Ahmed D. El-Mekkawy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Dr. Radut | forum