Question: Write a python script that uses a csv.reader to loop through the records in your local /etc/passwd file and extract all the user descriptions (ie.

Write a python script that uses a csv.reader to loop through the records in your local /etc/passwd file and extract all the user descriptions (ie. the fifth field).

It should basically be the Python equivalent of the following pipeline:

$ cat /etc/passwd | cut -d : -f 5 | sed '/^\s*$/d' | env LC_ALL=C sort 

Skeleton:

import csv # Constants PATH = '/etc/passwd' # TODO: Loop through ':' delimited data in PATH and extract the fifth field # (user description) users = None for record in csv.reader(None): pass # TODO: Print user descriptions in sorted order for user in sorted(users): pass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!