Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have bunch of wordpress sites that are hosted in shared hosting environment. As with every wordpress site there are "uploads" directory. I would like to search for potentially malicious files that are within those folders regularly but i dont want to ofcourse do it one by one.

So question is how can i search all "uploads" directories for a file with extension ".php"

For example:

find . -type d -iname "uploads"

gets me all the "uploads" folders in my root directory but i also want to search within those director

share|improve this question
up vote 3 down vote accepted

It's possible to pipe the output from your command to another, but you can search for both criteria at once, using grep and Regular Expressions:

find . -type f | grep -i "/uploads/.*\.php$"

How it works:

  • find . -type f lists all files in the current directory and its subdirectories.

  • grep -i "/uploads/.*\.php$" filters the output:

    • -i makes the search case-insensitive

    • /uploads/.*\.php$ is the regular expression a line has to match in order to get displayed

      • /uploads/ php are exactly that

      • .* is any number of occurrences of any type of characters

      • \. is a literal .

      • $ signals the end of the line

You can achieve the same result with

find . -type f -iregex ".*/uploads/.*\.php"

but the syntax is a hassle if you know Regular Expressions from grep, Perl, PHP, JavaScript, etc.

share|improve this answer
Yep that was it. Thank you good sir. – user16877 Apr 13 '12 at 21:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.