Can someone help me with a command line to find all .php files on a server with a number in the filename?

I have searched, as best I can, for other answers, but they typically show for a specific file name structure (such as c[0-9][4-7]_list.txt), my need is ANY filename with a number in it and a .php extension, for example:

push1.php 23test.php up22date.php

Would all be valid for my search purposes.

Reasons for wanting: hacked Wordpress install, where I am finding multiple files added to directories with this kind of structure. I am auditing all files, but I feel starting with these most likely candidates are my priority (along with password changes, obviously).

Many thanks for any help given, or a slap and pointed to another answer already given would also be appreciated :-)

  • Have you looked at the date the files were created - I generally find that when cleaning a hacked WP install that the date of files is a dead giveaway. – davidgo Jul 23 '15 at 8:45
  • Appreciated input, I'm doing that now. – Justin Jul 23 '15 at 10:06
  • Turned out that, having a purchased theme that doesn't update automagically, there was a massive security hole in the theme that made everything else I was doing pointless - 12 hours of battling the spamming rude words here. Correct notifications of theme updates added and a rather red face for having let it happen in the first place. – Justin Jul 24 '15 at 13:43

Use find to locate files - using the numeric character set [0-9] to match files with a number, and suffix .php

find . -name \*[0-9]\*.php
  • Glad it helped. BTW you don't know - but it is customary to accept the answer that works for you and upvote answers that you approve of (when you have reputation to upvote). – suspectus Jul 24 '15 at 11:17
  • I did upvote, but have since realised, and now had confirmed by you, that I don't yet have enough reputation to make that show on the site. I will, of course, do that again when I've got the reputation to do so. Many thanks again. – Justin Jul 24 '15 at 13:40

find . -name '[0-9].php'

Should find any file with a number in it.

  • Code formatting appears to be wrong in your post. I presume you meant to say find . -name '*[0-9]*.php' but the markdown is wrong. – DavidPostill Jul 23 '15 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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