find Cmmand - Recursive Search of Directories

You can use the find command to perform a recursive search for a directory.

find DirectoryName

This is a sample to search under "/usr/local/lib".

find /usr/local/lib

This is a sample output result.

/usr/local/lib
/usr/local/lib/liblept.so.3.0.0
/usr/local/lib/liblept.so.3
/usr/local/lib/liblept.so
/usr/local/lib/liblept.la
/usr/local/lib/liblept.a
/usr/local/lib/libtesseract.so.3.0.2
/usr/local/lib/libtesseract.so.3
/usr/local/lib/libtesseract.so
/usr/local/lib/libtesseract.la
/usr/local/lib/libtesseract.a
/usr/local/lib/pkgconfig
/usr/local/lib/pkgconfig/tesseract.pc

Narrow down the contents of the find command

When combined with the grep command, you can narrow down the content of the find command.

find /usr/local/lib | grep pkg

This is a sample output result.

/usr/local/lib/pkgconfig
/usr/local/lib/pkgconfig/tesseract.pc

Specify the current directory that does not contain hidden files

If you currently have a hidden directory such as ".git" used by Git in your directory and you don't want to include it, you can use the wildcard "*". Is convenient to use. This applies to files other than hidden files in the current directory.

find *

Specify the file type

With the find command, you can specify the file type, such as a directory or regular file, with the "-type" option.

Normal file

With f specified, only normal files that do not contain directories or symbolic links are fetched.

find -type f filename

Directory files

With d specified, only the directory is fetched.

find -type d filename

List of types

A list of file types specified by type.

b block (buffer) special
c characters (no buffer) special
d directory
p Named Pipe (FIFO)
f Normal file
l Symbolic links; this is never the case with the -L option or -follow The option is valid as long as the symbolic link is not broken. If you Search for symbolic links when -L is enabled -xtype.
s socket

Narrow down to executable files only

To narrow down to only executable files, specify "-executable" in addition to f specification.

find -executable -type f filename

Associated Information