The find command

The find command is a powerful way to operate recursively on a directory hierarchy. This means that you can provide it with a set of directories (or files), and it will apply appropriate tests and actions to them and also to any directories and files within them, such as children and grandchildren.

The default action for find is to print the filenames as it finds them:

$ find ~/recipes
/home/bashuser/recipes
/home/bashuser/recipes/lemon-garlic-fish.txt
/home/bashuser/recipes/japanese
/home/bashuser/recipes/japanese/katsu-curry.txt
/home/bashuser/recipes/gnocchi-and-sauce.doc

You can make this explicit with the -print action:

$ find ~/recipes -print

As long as there aren't too many files in the directory tree at that point, ...

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.