Bird
0
0

What will be the output of this command?

medium📝 Command Output Q5 of 15
Bash Scripting - Text Processing in Scripts
What will be the output of this command?
grep -v "error" log.txt

Assuming log.txt contains:
error: file not found
success: file saved
error: access denied
Aerror: file not found success: file saved error: access denied
Bsuccess: file saved
Cerror: access denied
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand -v option

    The -v option inverts the match, so grep prints lines NOT containing "error".
  2. Step 2: Check lines in log.txt

    Only "success: file saved" does not contain "error", so only this line is printed.
  3. Final Answer:

    success: file saved -> Option B
  4. Quick Check:

    -v inverts grep matches [OK]
Quick Trick: Use -v to show lines without the pattern [OK]
Common Mistakes:
MISTAKES
  • Expecting all lines to print
  • Confusing -v with -i
  • Assuming -v deletes lines

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes