Linux Find syntax

Let's say I wanted to find all php files created on the server within the past month.  What would the syntax be?

find / -name *.php ...and?

Thanks!
LVL 2
erzoolanderAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
woolmilkporcConnect With a Mentor Commented:
find / -name "*.php" -ctime -30

will find all files whose inode information was changed within the last 30 days.
File creation times don't get recorded in Linux/Unix, unfortunately.
0
 
Dan CraciunConnect With a Mentor IT ConsultantCommented:
find / -type f -name "*.php" -newermt 2014-01-01
0
 
woolmilkporcConnect With a Mentor Commented:
OK,

in case your "find" doesn't support "-newermt" and if you really want to find all "*.php" files from the last calendar month (Dec. 2013 in our case) then try this:

touch -t $(date -d "1 month ago" "+%Y%m")"010000" /tmp/from
touch -t $(date "+%Y%m")"010000" /tmp/to
find / -name "*.php" -newer /tmp/from ! -newer /tmp/to
rm /tmp/from /tmp/to

The script calculates the last month and the corresponding year on its own, no need to customize anything.
0
 
SandyConnect With a Mentor Commented:
find / -name "*.php" -ctime -30
0
All Courses

From novice to tech pro — start learning today.