Linux Questions & Answers on Search Pattern for Freshers

1. Which option of grep displays the line number as well?

a) -v
b) -l
c) -n
d) -E
Answer: c
2. How can you search for blank line in a file?

a) $ grep “ “ file
b) $ grep “^$” file
c) $ grep [“ “] file
d) $ grep [^$] file
Answer: b
3. Assuming the files fileA, fileB, fileAB, fileBC and fileABC, exist in a directory, which files match with the pattern file[ABC]?

a) fileA, fileB and fileABC
b) fileABC
c) fileA and fileB
d) fileAB, fileBC and fileABC
Answer: c
4. What will be printed for the command below?
$ grep –c “^echo” abc

a) The count of lines that do not contain the pattern echo in file abc
b) The count of lines which begin with the pattern echo in file abc
c) The count of lines that ends with the pattern echo in file abc
d) None of the mentioned
Answer: b
5. Which one is used to select only one copy of the repeated lines?

a) uniq -u
b) uniq -d
c) uniq -c
d) uniq –I
Answer: a
6. Indicate the right option to search for BOB, Bob, BOb or BoB?

a) grep –i Bob files
b) grep ‘B[oO][bB]’ files
c) grep ‘[BOB]’ files
d) grep -v ‘Bob’ files
Answer: b
7. 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 mentioned
Answer: b
8. 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
Answer: a
9. One of the entry of /etc/passwd file is shown below:
user1:x:1111:2222:Sanfoundry:/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
Answer: a
10. who | cut –d ” ” -f1
what is the ouput if the who command displays like this
user1 tty 0 1234

a) user1
b) user1 tty 0 1234
c) tty
d) tty 0 1234
Answer: a
11. What is the command that can print lines of first file matching with second file?

a) printline
b) cmp
c) com
d) comm
Answer: d
12. Which character to use to escape meaning of special characters in search operations?

a) [].
b) ^
c) .
d)
Answer: d

Related

Computer Fundamentals Multiple choice Questions and Answers on Registers for Freshers

1. CPU has built-in ability to execute a particular set of machine instructions, called as __________ a) Instruction Setb) Registersc) Sequence Setd) User instructions Answer: a Explanation: An i...

Multiple choice Questions and Answers on Managing and Monitoring SOA of Cloud Computing for Freshers

1. Which of the following products have SOA management tool ? a) HP Software and Solutions OpenView SOA Manager b) IBM Tivoli Framework Composite Application Manager c) Oracle BPEL Process Manager ...

Computer Fundamentals Multiple choice Questions and Answers on CPU & Control Unit for Freshers

1. Brain of computer is ____________ a) Control unitb) Arithmetic and Logic unitc) Central Processing Unitd) Memory Answer: c Explanation: The CPU is referred to as the brain of a computer.It con...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item