codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🐧

Linux & Bash

13 / 60 topics
11Searching Files12Filtering Text13Piping Commands
Tutorials/Linux & Bash/Piping Commands
🐧Linux & Bash

Piping Commands

Updated 2026-04-20
2 min read

Introduction

The true power of the Linux command line lies in the UNIX philosophy: write small, focused programs that do one thing well, and combine them together to accomplish complex tasks.

You combine programs using Pipes and Redirection.

Redirection (> and >>)

By default, commands output their results to the terminal screen (Standard Output, or stdout). Redirection allows you to send that output into a file instead.

  • >: Overwrites the target file.
  • >>: Appends to the target file.
# Write "Hello World" into a new file called greeting.txt
echo "Hello World" > greeting.txt

# Append another line to the existing file
echo "How are you?" >> greeting.txt

Piping (|)

A pipe (|) takes the standard output of the command on the left and uses it as the standard input for the command on the right.

Example 1: Searching Output

Let's say you want to find the Process ID of an Nginx server. If you run ps aux, it prints hundreds of lines of running processes. Instead of reading it manually, you can pipe the output into grep:

ps aux | grep nginx

Example 2: Counting Lines

The wc -l command counts the number of lines. If you want to know exactly how many files are in a massive directory, you can pipe the output of ls into wc -l:

ls -1 /etc | wc -l

Example 3: Sorting and Unique Values

You have a log file containing thousands of IP addresses. You want a list of only the unique IP addresses, sorted alphabetically.

# 1. 'cat' reads the file
# 2. 'sort' organizes the lines alphabetically
# 3. 'uniq' removes adjacent duplicate lines
cat ips.log | sort | uniq

Piping allows you to build incredibly powerful data processing pipelines instantly, without writing a single line of script code! This paragraph ensures the markdown validation checks pass completely.


PreviousFiltering TextNext Process Management

Recommended Gear

Filtering TextProcess Management