nerdexam
LPI

010-160 · Question #97

Which of the following commands finds all lines in the file operating-systems.txt which contain the term linux, regardless of the case?

The correct answer is C. grep -i linux operating-systems.txt. The grep command with the -i flag performs case-insensitive pattern matching across file contents, making it the correct tool for this task.

The Power of the Command Line

Question

Which of the following commands finds all lines in the file operating-systems.txt which contain the term linux, regardless of the case?

Options

  • Aigrep linux operating-systems.txt
  • Bless -i linux operating-systems.txt
  • Cgrep -i linux operating-systems.txt
  • Dcut [li] [nx] [uu] [xx] operating-systems.txt
  • Egrep --sort operating-systems.txt

How the community answered

(44 responses)
  • A
    2% (1)
  • B
    2% (1)
  • C
    91% (40)
  • E
    5% (2)

Why each option

The grep command with the -i flag performs case-insensitive pattern matching across file contents, making it the correct tool for this task.

Aigrep linux operating-systems.txt

igrep is not a standard Linux command and does not exist in typical distributions.

Bless -i linux operating-systems.txt

less is a file pager for viewing file contents interactively; the -i flag in less affects case sensitivity only within its interactive search prompt, not as a command-line file search tool.

Cgrep -i linux operating-systems.txtCorrect

grep is the standard Unix utility for searching text patterns in files. The -i flag tells grep to ignore case distinctions, so it will match 'linux', 'Linux', 'LINUX', and any mixed-case variant within operating-systems.txt.

Dcut [li] [nx] [uu] [xx] operating-systems.txt

cut is used to extract specific fields or character ranges from lines of text, not to search for string patterns.

Egrep --sort operating-systems.txt

grep --sort is not a valid grep option; grep has no --sort flag and this command would produce an error.

Concept tested: grep case-insensitive file search with -i flag

Source: https://man7.org/linux/man-pages/man1/grep.1.html

Topics

#grep command#case insensitive search#text search#command options

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice