-r, -R, --recursive (Recursive): Apply the operation to every file in a directory tree, going into all sub-directories. A recursive flag applies a command to a folder and everything inside it, all the way down. cp -r copies a whole directory tree. grep -r 'TODO' src/ searches every file under src. chmod -R changes permissions on every file and folder below a path.
Frequently asked questions about -r, -R, --recursive (Recursive)
How is -r, -R, --recursive (Recursive) used in practice?
Without it, most commands stop at the folder itself. cp refuses to copy a directory at all unless you add -r.
What should you keep in mind with -r, -R, --recursive (Recursive)?
Recursive actions multiply mistakes. A chmod -R 777 on the wrong path can open up a whole server, and rm -rf on a variable that turned out to be empty can remove far more than you meant. In scripts, check that the path is set and is what you expect before you run anything recursive on it. Some tools use -r and others -R, and a few treat them differently, so check the help text.
Use before running or suggesting shell commands with flags, especially destructive or broad ones (-f/--force, -r/-R recursive, -a/--all, -y/--yes, prune, --hard), and when a user asks what a flag means (-v, -q, -n/--dry-run, -h, -o, -p, -t, -u, -w, -x, -c, -i). Explains flags per tool and prefers dry runs and narrow scopes.
Use this skill before running, or recommending, any Docker command that deletes, wipes, resets, or otherwise irreversibly changes state — even if the user just says to "clean up", "clear the cache", "start fresh", "wipe everything", "nuke it", "reset", "force remove", or "tear down" Docker resources. Covers generic Docker CLI destructive operations not owned by a more specific skill — `docker rm`,
Master ShellCheck static analysis configuration and usage for shell script quality. Use when setting up linting infrastructure, fixing code issues, or ensuring script portability.