Bird
0
0

Which of the following correctly demonstrates how to connect the output of ls to the input of grep using a pipe in Linux?

easy📝 Syntax Q3 of 15
Linux CLI - Pipes and Redirection
Which of the following correctly demonstrates how to connect the output of ls to the input of grep using a pipe in Linux?
Als | grep 'txt'
Bls > grep 'txt'
Cls & grep 'txt'
Dls ; grep 'txt'
Step-by-Step Solution
Solution:
  1. Step 1: Understand pipe usage

    The pipe symbol | sends the output of the command on its left as input to the command on its right.
  2. Step 2: Analyze options

    ls | grep 'txt' uses | correctly to connect ls and grep. ls > grep 'txt' uses redirection incorrectly, ls & grep 'txt' runs commands in background separately, and ls ; grep 'txt' runs commands sequentially but not connected.
  3. Final Answer:

    ls | grep 'txt' -> Option A
  4. Quick Check:

    Pipe symbol | connects commands [OK]
Quick Trick: Use | to pass output as input between commands [OK]
Common Mistakes:
  • Using > instead of | for piping
  • Using & which runs commands in background
  • Using ; which runs commands sequentially but not piped

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes