Bird
0
0

What does the grep command do when used inside a bash script?

easy🧠 Conceptual Q1 of 15
Bash Scripting - Text Processing in Scripts
What does the grep command do when used inside a bash script?
ACreates a backup of the script file
BDeletes files containing a specific word
CCompiles the script for faster execution
DSearches for matching text patterns in files or input
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of grep

    The grep command is designed to search text for patterns and print matching lines.
  2. Step 2: Identify grep's role in scripts

    In scripts, grep helps find specific text within files or input streams, not deleting or compiling.
  3. Final Answer:

    Searches for matching text patterns in files or input -> Option D
  4. Quick Check:

    grep function = search text [OK]
Quick Trick: grep finds text patterns in files or input streams [OK]
Common Mistakes:
MISTAKES
  • Thinking grep deletes files
  • Confusing grep with compilation commands
  • Assuming grep creates backups

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes