Which of the following commands would display the lines containing capital letters form the file “turkey.txt”?

Which of the following commands would display the lines containing capital letters form the file "turkey.txt"?

Which of the following commands would display the lines containing capital letters form the file "turkey.txt"?

A.
cat turkey.txt|wc -l

B.
grep -n [A-Z] turkey.txt

C.
cat turkey.txt|wc -w [A-Z]

D.
grep -v [A-Z] < turkey.txt

E.
for [A-Z] in turkey.txt | count

Explanation/Reference:
A) would display the linecount of all lines in turkey.txt
C) would display an error
D) would display all lines not containing capital letters
E) would display an error



Leave a Reply 3

Your email address will not be published. Required fields are marked *


wangdan(china)

wangdan(china)

i have try the answer “B”,but the output are incorect, why not is “grep -n [A-Z].* turkey.txt”,my system version is CentOS 6.x x86_64,Grep version 2.6.3

Raza

Raza

try this;
grep [A-Z] file-name

Raza

Raza

indeed B is correct