Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started