Power Combos
Commands AI Tools Actually Run
Now that you understand redirection and pipes individually, let’s look at the combinations that AI coding tools use all the time. These are patterns you’ll see Claude Code, Cursor, and similar tools run constantly when they’re working on your projects.
Each of these takes commands you already know and chains them together into something genuinely powerful.
Counting Files by Type
find . -name "*.js" | wc -l
This finds every JavaScript file in the current directory (and all subdirectories), then counts how many there are. Your AI tool might run this to understand how big a project is or what languages it uses.
Try it now: Type find ~/projects/my-app -name "*.js" | wc -l
Counting TODOs in a Codebase
grep -r "TODO" src/ | wc -l
This searches recursively through every file in src/ for the word “TODO”, then counts the total number of matches. A quick way to see how much unfinished work is flagged in a project.
Try it now: Type grep -r "TODO" ~/projects/my-app/src/ | wc -l
Counting Errors in a Log
cat logs/error.log | grep "ERROR" | wc -l
This reads a log file, filters for lines containing “ERROR”, then counts them. Instead of scrolling through an entire log to figure out how bad things are, you get a single number.
Try it now: Type cat ~/projects/my-app/logs/error.log | grep "ERROR" | wc -l
Finding Files While Excluding Directories
find . -name "*.js" -type f | grep -v node_modules
This finds all JavaScript files, then uses grep -v to exclude any results containing “node_modules”. The -v flag inverts the match — it shows everything that does not match the pattern.
This is incredibly common. In a Node.js project, node_modules can contain thousands of JavaScript files you don’t care about. This combo filters them out.
Try it now: Type find ~/projects/my-app -name "*.js" -type f | grep -v node_modules
The
-v flag in grep means "invert" — show lines that do NOT match. This is one of the most useful flags to know. You'll see it constantly in piped commands where you need to exclude noise from results.
Saving Results to a File
You can combine pipes and redirection together:
find . -name "*.js" -type f | grep -v node_modules > js-files.txt
This finds all JavaScript files, excludes node_modules, and saves the result to a file instead of printing it on screen. Useful when you want to keep a record or share the output.
Reading These Combos
When you see a long piped command from an AI tool, don’t panic. Read it left to right, one pipe at a time:
| Command | Step 1 | Step 2 | Step 3 |
|---|---|---|---|
find . -name "*.js" \| wc -l |
Find JS files | Count them | — |
grep -r "TODO" src/ \| wc -l |
Search for TODOs | Count matches | — |
cat log \| grep "ERROR" \| wc -l |
Read the log | Filter errors | Count them |
find . -name "*.js" \| grep -v node_modules |
Find JS files | Exclude node_modules | — |
Every complex command is just simple steps chained together. You already know every individual command in these combos from earlier modules. The pipe is the only new part.
Practice
Try each of these in the terminal:
find ~/projects/my-app -name "*.js" | wc -l— count JavaScript filesgrep -r "TODO" ~/projects/my-app/src/ | wc -l— count TODO commentscat ~/projects/my-app/logs/error.log | grep "ERROR" | wc -l— count errorsfind ~/projects/my-app -name "*.js" -type f | grep -v node_modules— JS files without node_modulesls -la ~/projects/my-app | grep ".js" | wc -l— count JS files in the top-level directory