Book Image

Linux Shell Scripting Essentials

Book Image

Linux Shell Scripting Essentials

Overview of this book

Table of Contents (15 chapters)
Linux Shell Scripting Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Finding files


In a filesystem, there is huge number of files available. Sometimes, there are external devices that are attached as well, which may also contain huge number of files. Imagine that there are millions and billions of files in a system and in which we have to search for a specific file or pattern of a file. Manual searching of a file is possible if the number of files is from 10 to 100, but it is almost impossible to search in millions of files. To solve this problem, UNIX and Linux provide the find command. It is a very useful command for searching files in a computer.

The syntax of using the find command is as follows:

find search_path [option]

Here, in search_path, specify the path in which find should search for file_search_pattern.

A few important options are mentioned in the following table:

Option

Description

-P

Don't follow symbolic link. This is default behavior

-L

Follow symbolic link while searching

-exec cmd ;

Execute command cmd passed as parameter to -exec

...