Back to Blog
Arnošt Havelka

Command Pipelines

Connect commands together with pipes to create powerful workflows.

Start Interactive Lesson
Command Pipelines

Command Pipelines

Pipes (|) connect commands together, sending the output of one command as input to the next. This is where Bash becomes truly powerful.

Basic Pipe: |

The | operator chains commands together. Think of it as "pass the output to the next command."

Usage:command1|command2
|
Pipe - sends output from command1 to command2 as input.

Chain commands together:

Command Prompt
INFO: Started ERROR: Connection failed INFO: Retrying ERROR: Timeout
C:\Users\User>cat log.txt

Multiple Pipes

Chain as many commands as you need. Each passes output to the next.

Usage:command1|command2|command3
command1 | command2 | command3
Chain multiple pipes for complex processing.

Process step by step:

Command Prompt
alice zoe bob alice carol
C:\Users\User>cat names.txt

Pipe With Grep and wc

Count matching lines with a pipe chain.

Command Prompt
INFO: Message 1 ERROR: Problem INFO: Message 2 ERROR: Issue ERROR: Fail
C:\Users\User>cat log.txt

Real-World Example

Extract and count web server errors.

Command Prompt
200 /index.html 404 /missing.html 200 /about.html 404 /error.html 500 /api
C:\Users\User>cat access.log

Knowledge Check

1 / 3

What does the pipe operator | do?

References

These Microsoft Learn and Windows documentation links provide authoritative details for the commands used in this article.

Up Next

Practice: Data Extraction

Combine grep, pipes, and redirection to extract and analyze data.