LPI Exam Questions

Which of the following commands shows ONLY the user id of Bob?

Which of the following commands shows ONLY the user id of Bob?

(Select TWO)

A.
cat /etc/passwd | grep Bob | cut -d: -f3

B.
cat /etc/passwd | grep Bob | cut -f: -d3

C.
grep Bob /etc/passwd | awk -F: ‘{ print $3 }’

D.
grep Bob /etc/passwd | awk -f: ‘{ print $3 }’

E.
grep Bob /etc/passwd | cut -F: -d3

Explanation:
UID is in the 3rd column of /etc/passwd, the columns are separated by ":"
cut option -d lets us specify the separator, as does awk option -F