Lion Cipher Lab
Combine commands with pipes, redirection, and xargs
- Foundations
- Intermediate
- ~40 min
- Free · no account required
Why it matters
The reason the command line feels like a superpower to people who are fluent in it — and a wall to everyone else — is one idea: tiny single-purpose tools snap together into exactly the tool you need, right now, that nobody shipped. That snapping-together is plumbing: a pipe hands one command's output to the next, redirection sends output into a file or throws it away, and xargs turns a list of results into the arguments for a command that would otherwise ignore it. Every other command-line skill you will ever learn — grep, sed, awk, docker, git, kubectl, every security tool — assumes you…
What you'll learn
- understanding the three standard streams (stdin, stdout, stderr) and file descriptors 0/1/2
- connecting commands with a pipe |
- redirecting output with > >> and input with <
- capturing and merging errors with 2> 2>&1 &> and silencing with /dev/null
- building a multi-stage top-N pipeline (sort | uniq -c | sort -rn | head)
- splitting a stream with tee to save and keep piping
- using command substitution $(...) vs a pipe
- turning stdin into arguments with xargs, safely with find -print0 | xargs -0
- chaining with ; && || and reading exit status $?
Steps in this lab
- The one mental model: streams, and a pipe between them
- Build a sample file to drive everything (heredoc)
- Redirection to files: >, >>, < — and the clobber footgun
- See stdout and stderr as two separate channels
- Build a real pipeline: the top-N idiom
- tee: save a stream AND keep piping it
- xargs: when a pipe isn't enough (stdin as arguments)
- Chaining and exit status: ;, &&, || and $?
- Judgment: when plumbing is right, when it bites, and how a pro works
- You now own the plumbing under every command-line tool