Finding files and file listing

find is one of the great utilities in the UNIX/Linux command-line toolbox. It is a very useful command for shell scripts, but most people do not use it effectively due to the lack of understanding. This recipe deals with most of the use cases of find and how it can be used to solve problems of different criterions.

Getting ready

The find command uses the following strategy: find descends through a hierarchy of files, matches the files that meet specified criteria, and performs some actions. Let's go through different use cases of find and the basic usages.

How to do it...

In order to list all the files and folders from the current directory to the descending child directories, use the following syntax:

$ find base_path ...

Get Linux Shell Scripting Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.