nerdexam
Cisco

350-201 · Question #130

Which bash command will print all lines from the "colors.txt" file containing the non case-sensitive pattern "Yellow"?

The correct answer is A. grep -i "yellow" colors.txt. The grep command with the -i flag performs case-insensitive pattern matching within file contents, printing all matching lines.

Automation

Question

Which bash command will print all lines from the "colors.txt" file containing the non case-sensitive pattern "Yellow"?

Options

  • Agrep -i "yellow" colors.txt
  • Blocate "yellow" colors.txt
  • Clocate -i "Yellow" colors.txt
  • Dgrep "Yellow" colors.txt

How the community answered

(25 responses)
  • A
    88% (22)
  • C
    8% (2)
  • D
    4% (1)

Why each option

The grep command with the -i flag performs case-insensitive pattern matching within file contents, printing all matching lines.

Agrep -i "yellow" colors.txtCorrect

The grep -i flag enables case-insensitive matching, so 'grep -i "yellow" colors.txt' will match and print lines containing 'yellow', 'Yellow', 'YELLOW', or any mixed-case variant from the file colors.txt. The -i flag is the standard POSIX grep option for case-insensitive content search.

Blocate "yellow" colors.txt

The locate command searches the file system index for files matching a name pattern and does not search within file contents.

Clocate -i "Yellow" colors.txt

locate does not support a -i flag for content searching and does not read file contents - it only locates files by name in the system database.

Dgrep "Yellow" colors.txt

grep without -i performs a case-sensitive match, so 'grep "Yellow"' would only match lines with that exact capitalization and would miss 'yellow' or 'YELLOW'.

Concept tested: grep case-insensitive file content pattern matching

Source: https://www.gnu.org/software/grep/manual/grep.html

Topics

#bash scripting#grep#pattern matching#command line

Community Discussion

No community discussion yet for this question.

Full 350-201 Practice