Linux Search Pattern Question:

Download Job Interview Questions and Answers PDF

One of the entry of /etc/passwd file is shown below:
user1:x:1111:2222:google:/home/user1:/bin/bash
Which among the following will print userid and home dir in the following pattern "user1:/home/user1"?
a) awk `{print $1 ":" $6}` /etc/passwd
b) awk `{print $1 ":" $7}` /etc/passwd
c) awk `{print $2 ":" $6}` /etc/passwd
d) awk `{print $2 ":" $7}` /etc/passwd

Search Pattern Interview Question
Search Pattern Interview Question

Answer:

a) awk `{print $1 ":" $6}` /etc/passwd

Download Search Pattern Interview Questions And Answers PDF

Previous QuestionNext Question
Indicate the right option to search for anything not a letter or number:
a) grep '^[a-zA-Z0-9]'
b) grep '[^a-zA-Z0-9]'
c) grep '[a-zA-Z0-9]'
d) None of the above in Search Pattern
How do you remove duplicate lines from the file foo using uniq?
a) sort foo | uniq -u
b) sort -u foo | uniq -d
c) sort foo | uniq -c
d) sort foo | uniq -I