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; however, many people do not use it to its fullest effectiveness. This recipe deals with most of the common ways to utilize find to locate files.
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 its basic usages.
How to do it...
To list all the files and folders from the current directory to the descending child directories, use the following syntax:
$ find base_path
base_path can be any location from which find should start descending (for example, /home/slynux/).
An example of this command is as follows:
$ find . -print # Print lists of files and folders
. specifies current directory and .. specifies the parent directory. This convention is followed throughout the Unix...