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.
Question
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)- A2% (1)
- B2% (1)
- C91% (40)
- E5% (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.
igrep is not a standard Linux command and does not exist in typical distributions.
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.
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.
cut is used to extract specific fields or character ranges from lines of text, not to search for string patterns.
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
Community Discussion
No community discussion yet for this question.