WordPress Developer & Linux Administrator

Finding files quickly and easily with Linux

The Linux `find` command is a great way to locate files quickly and easily. Whether you’re looking for files by name, or needing to find files containing text, this is what you need.

Find files by name, recursively

This one will find all files in the current directory or lower that contains “searchbythis” in the filename.

find . -name "*searchbythis*.jpg" 

Find files by name, recursively, excluding certain files by criteria

This one will find all files in the current directory or lower that contains “searchbythis” in the filename. Additionally, it will exclude results that contain “certaintext” or “moretext” in the filename.

find . -name "*searchbythis*" | grep -v certaintext | grep -v moretext 

Find all .jpg files recursively

find . -name "*.jpg"

Find while ignoring cAsE

By using the iname flag (as opposed to -name), you can run case insensitive searches to find what you’re looking for.

find . -iname "sEaRcHtExT"

The following should return results matching…

  • searchtext
  • Searchtext
  • SearchText
  • searchTEXT
  • sEaRcHtExT
  • etc.
Categories: Commands

Comments

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