0
0
Linux CLIscripting~15 mins

Pipe operator (|) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the Pipe Operator (|) in Linux Command Line
📖 Scenario: You are working on a Linux system and want to process text data efficiently by combining commands.
🎯 Goal: Learn how to use the pipe operator | to send the output of one command as input to another command.
📋 What You'll Learn
Use the echo command to create text output
Use the grep command to filter lines containing a specific word
Use the pipe operator | to connect commands
Display the filtered result on the terminal
💡 Why This Matters
🌍 Real World
Using pipes is common in Linux to combine simple commands for powerful text processing without creating temporary files.
💼 Career
Many IT and developer jobs require using pipes to quickly analyze logs, filter data, and automate tasks efficiently.
Progress0 / 4 steps
1
Create a text output with echo
Write a command using echo to output the following three lines exactly: apple, banana, and cherry, each on its own line.
Linux CLI
Need a hint?

Use echo -e with \n to create new lines.

2
Add a filter word variable
Create a variable called word and set it to banana.
Linux CLI
Need a hint?

Use word=banana without spaces around the equals sign.

3
Use the pipe operator to filter output
Use the pipe operator | to send the output of the echo command to grep. Use grep with the variable word to filter lines containing banana.
Linux CLI
Need a hint?

Use | between echo and grep. Use double quotes around $word.

4
Display the filtered result
Run the full command to display only the line containing banana on the terminal.
Linux CLI
Need a hint?

The output should show only the word banana.