# Pipes & xargs — Linux Command Line Fundamentals

Source: https://www.skillbyai.com/en/linux/linux-pipes-xargs

> Chain commands with pipes and turn output into arguments with xargs for flexible one-liners.

## | chains commands

A pipe feeds one command's stdout as the next command's stdin, so small tools combine into a pipeline.

```bash
ps aux | grep nginx | wc -l
```

Output:

```
2
```

## xargs — turn lines into arguments

`xargs` takes lines from stdin and passes them as arguments to another command — useful when a command doesn't read stdin itself.

```bash
find . -name "*.tmp" | xargs rm
```

**Quiz:** What does the `|` operator do?

- [ ] Runs two commands in parallel
- [ ] Comments out the rest of the line
- [x] Sends one command's output as the next command's input
- [ ] Creates a hard link

*Answer:* Sends one command's output as the next command's input. That's exactly what a pipe does — connect stdout to the next command's stdin.
