Question: Given the following Unix pipelines, write Python scripts (ie. translateX.py) that accomplishes the same task. translate1.py: grep -Po ':1d*0:' /etc/passwd | wc -l translate2.py: /bin/ls

Given the following Unix pipelines, write Python scripts (ie. translateX.py) that accomplishes the same task.

translate1.py: grep -Po ':1\d*0:' /etc/passwd | wc -l

translate2.py: /bin/ls -ld /etc/* | awk '{print $4}' | sort | uniq

translate3.py: curl -sLk http://yld.me/raw/fDIO | cut -d , -f 4 | grep -Eo '^M.*' | sort

translate4.py: cat /etc/passwd | cut -d : -f 7 | sort | uniq -c | sort -srn

Notes

No credit will be given for simply calling os.system or os.popen on the given pipeline.

You may use os.popen to read the output of a single command, but not for a pipeline.

Use functional programming, list comprehensions, or generator expressions whenever possible.

You do not need to do a literal translation (that is you don't have to replicate each portion of the pipeline); you just need to accomplish the same overall task and emit the same output.

Most of the scripts should only be 5 - 10 lines long.

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!