?
Solved

Linux Find syntax

Posted on 2014-01-29
4
Medium Priority
?
443 Views
Last Modified: 2014-02-14
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!
0
Comment
Question by:erzoolander
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1000 total points
ID: 39818831
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
 
LVL 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 500 total points
ID: 39818836
find / -type f -name "*.php" -newermt 2014-01-01
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 1000 total points
ID: 39818942
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
 
LVL 13

Assisted Solution

by:Sandy
Sandy earned 500 total points
ID: 39823432
find / -name "*.php" -ctime -30
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question