DELAPARRA
Index
Color
NL
Category: CLI flags

-r, -R, --recursive (Recursive)

Explained by Updated

What is -r, -R, --recursive (Recursive)?

-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.

Definition source Coders Lingo, CC BY 4.0

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.

At a glance

CategoryCLI flags
Explained by
Updated

More CLI flags terms

All terms starting with a number or symbol

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.