Also called: for loop, if [ ], test
Example
A short for loop converted all 200 photos to WebP.
In code
for f in *.jpg; do
cwebp -q 80 "$f" -o "${f%.jpg}.webp"
done
if [ -f .env ]; then echo "env exists"; else cp .env.example .env; fi
Learn more
- Conditional ConstructsGNU manual (opens in a new tab)
- Looping ConstructsGNU manual (opens in a new tab)
Related terms
Added 2026-11-30 · Last reviewed 2026-11-30