Linux find command explain with examples

Published September 22, 2009 by Siva

To find all files ending with .html:

find / -name \*.html -print

The character causes the shell to ignore the following character, in this case an asterisk. To find a file that starts with project:

find / -name project\* -print

Multiple wildcards can be used in the same find command. The following command finds all files with the word maybe in it:

find / -name \*maybe\* -print

The backslash \ character is important. It tells the shell not to treat the wildcard character as a wildcard when interpreting the command line arguments.

To find all empty files on the entire system,

find / -size 0 -print

To find all empty files from the current directory down,

find . -size 0 -print

To find all empty files on the entire system,

find / -size 0 -print

To find all empty files from the current directory down,

find . -size 0 -print

To find all files with zero length and ask if they should be deleted:

find / -size 0 -ok rm {} \;

The backslash \ is important because it tells the shell to ignore the semicolon symbol which usually separates commands on a single command line.

Advertisements

2 comments on “Linux find command explain with examples

  • Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    %d bloggers like this: