Bird
0
0

You run grep alice /var/log/cron tail -n 3 but get an error: 'grep: invalid option -- n'. What is the mistake?

medium📝 Troubleshoot Q7 of 15
Linux CLI - Cron and Scheduling
You run grep alice /var/log/cron tail -n 3 but get an error: 'grep: invalid option -- n'. What is the mistake?
AThe command should be <code>tail -n 3 grep alice /var/log/cron</code>
BThe tail command should be used after grep, not as an option to grep
CThe file /var/log/cron does not exist
Dgrep does not support piping
Step-by-Step Solution
Solution:
  1. Step 1: Analyze error message

    grep reports invalid option -n, meaning tail's option was incorrectly passed to grep.
  2. Step 2: Check command syntax

    Correct syntax is to pipe grep output to tail: grep alice /var/log/cron | tail -n 3. If tail is inside grep, it causes error.
  3. Final Answer:

    The tail command should be used after grep, not as an option to grep -> Option B
  4. Quick Check:

    Pipe commands correctly: grep ... | tail ... [OK]
Quick Trick: Use pipe '|' to chain commands, not options inside commands [OK]
Common Mistakes:
  • Passing tail options inside grep command
  • Misplacing pipe symbol
  • Confusing command order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes