Lesson 155 of 1570
Bash and Shell With AI
The terminal is where real work happens. Pipes, variables, and loops in bash are a superpower — and AI is surprisingly good at shell one-liners.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1Everything Is a Stream
- 2pipe
- 3variable
- 4for loop
Concept cluster
Terms to connect while reading
Section 1
Everything Is a Stream
A command's stdout can be piped into the next command's stdin. That is the whole philosophy. Small tools, composed with `|`.
set -euo pipefail is the safety line. It makes scripts fail loudly instead of silently.
#!/usr/bin/env bash
set -euo pipefail
# Find the 5 largest files in the current tree
find . -type f -printf "%s %p\n" 2>/dev/null \
| sort -rn \
| head -n 5 \
| awk '{ printf "%.1f MB\t%s\n", $1/1024/1024, $2 }'A loop with variables
Arrays, quoted expansions, and curl's write-out format. The basics of a real ops script.
#!/usr/bin/env bash
set -euo pipefail
ENVS=(dev staging prod)
for env in "${ENVS[@]}"; do
url="https://${env}.example.com/health"
code=$(curl -s -o /dev/null -w "%{http_code}" "$url")
echo "$env -> $code"
doneThe big idea: small tools, piped together, with strict error handling and quoted variables. AI writes bash fluently — you just need to recognize the safety rules.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Bash and Shell With AI”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Builders · 30 min
Python Loops & Conditionals — Let AI Draft, You Decide
If-statements and loops are where programs come alive. You'll write both kinds, then see where AI autocomplete helps and where it lies.
Builders · 25 min
What Does AI-Assisted Coding Even Mean?
AI-assisted coding is not magic and not cheating. It is a new way of working where a model drafts, you decide. Let's draw a map before we start building.
Builders · 30 min
Your First Copilot-Style Completion
Let's actually feel what autocomplete is like. Write a comment, pause, and watch a full function appear. Then learn what to do next.
