Bird
0
0

What does the grep command do in a bash script?

easy🧠 Conceptual Q11 of 15
Bash Scripting - Text Processing in Scripts
What does the grep command do in a bash script?
ASearches for lines matching a pattern in files or input
BDeletes files matching a pattern
CCreates new files with matching names
DChanges file permissions based on a pattern
Step-by-Step Solution
Solution:
  1. Step 1: Understand grep's purpose

    The grep command is used to search text for lines that match a given pattern.
  2. Step 2: Compare options

    Options B, C, and D describe actions unrelated to searching text, so they are incorrect.
  3. Final Answer:

    Searches for lines matching a pattern in files or input -> Option A
  4. Quick Check:

    grep = search text lines [OK]
Quick Trick: grep finds text patterns in files or input quickly [OK]
Common Mistakes:
MISTAKES
  • Thinking grep deletes or modifies files
  • Confusing grep with commands like rm or chmod
  • Assuming grep creates files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes