QuickSnip
← Back to browse

Loop over files in Bash

Iterate over matching files and run a command on each.

Bash7 linesUpdated Jul 17, 2026
Edit
Bash
#!/usr/bin/env bash
set -euo pipefail

for file in src/**/*.ts; do
  echo "Processing $file"
  npx prettier --write "$file"
done