How to find a file in Unix

find command is used to search files and directories under Linux and Unix operating systems.

Find all PNG (*.png) images in current directory:
$ find . -name ‘*.png’
The . represent the current directory and the -name option specifies all png (image) files.

 

List of only .css files
$ find . -type f -name ‘*.css’

The -name command is case-sensitive.

 

Search in case insensitive mode
$ find . -iname ‘*.png’

Use -iname instead of -name to  ignore file name case sensitivity.
Search files by size

1. File size between 50 kb and 100 kb.

$ find . -size +50k -a -size -100k

2. Empty files.

$ find . -size 0k

3. Non-Empty files.

$ find . ! -size 0k

 

Set the search to start in the root directory.
To search file into the entire system, add the / modifier to the query.
This will search all directories starting from the root directory.

$ find / -iname “filename”

 

 

Please follow and like us:
0

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.