Find files using a wildcard in UNIX

Home -> UNIX

17796 views

From the computer of: qmchenry (339 recipes)
Created: Sep 02, 2003     Updated: Nov 28, 2003


Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

When you want to find all of the files matching a certain filename pattern, a wildcard can be used with the find command

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.

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  Unix/Linux: Easily find or search files or directories
  Delete Solaris files older than a certain date and time
  Find UNIX files with no valid owner
  Find all empty files in a UNIX filesystem
  Find help with man pages
  Find UNIX files modified within a number of days
  Solve your UNIX identity crisis
  Remove ^M characters at end of lines in vi
  How to empty or clear the contents of an existing UNIX file
  Find a file by name in UNIX/Solaris/Linux

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.