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
Get step-by-step solutions from verified subject matter experts
