Solved

Linux Find syntax

Posted on 2014-01-29
4
424 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
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 250 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 34

Assisted Solution

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

Assisted Solution

by:woolmilkporc
woolmilkporc earned 250 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 125 total points
ID: 39823432
find / -name "*.php" -ctime -30
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now