Bird
0
0

What will be the output of the command: ps aux | grep bash | wc -l if there are 3 bash processes running?

medium📝 Command Output Q5 of 15
Linux CLI - Pipes and Redirection
What will be the output of the command: ps aux | grep bash | wc -l if there are 3 bash processes running?
A4
B0
C2
D3
Step-by-Step Solution
Solution:
  1. Step 1: Understand ps aux and grep bash

    ps aux lists all processes. grep bash filters lines containing 'bash'. This includes the 3 bash processes plus the grep command itself.
  2. Step 2: Count lines with wc -l

    Since grep command line also contains 'bash', total lines are 4.
  3. Final Answer:

    4 -> Option A
  4. Quick Check:

    grep includes itself in output = 4 lines [OK]
Quick Trick: grep command appears in its own output unless excluded [OK]
Common Mistakes:
  • Ignoring grep process line
  • Assuming only matching processes count
  • Miscounting lines

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes