- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Perl with find
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 05:50 AM
тАО06-07-2007 05:50 AM
I found this one-liner on IRTC that James Ferguson came up with and it is very close to what I want. I am trying to decipher it and learn perl but am short on time right now and need a solution. It finds all files in a directory structure that have changed in the last 30 minutes. I need it to print out the files (including datestamps like ls -l would) that have been created or modified in the last 24 hours.
Thanks,
perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -M _ < 1/48},".")'
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 06:11 AM
тАО06-07-2007 06:11 AM
Re: Perl with find
Why not just use the 'find' command?
$ find /path -type f -mtime -1 -exec ls -l {} \;
But if you are set on using that perl one-liner, change '1/48' to '1' for the last 24 hours.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 06:15 AM
тАО06-07-2007 06:15 AM
Re: Perl with find
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 06:19 AM
тАО06-07-2007 06:19 AM
SolutionWhile I would agree with Spex for cases not involving fractional days, you could amend my snippet to something as simple as:
# perl -MFile::Find -le 'find(sub{print join " ",$File::Find::name,scalar localtime((stat($_))[9]) if -f $_ && -M _ <= 1},".")'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 06:23 AM
тАО06-07-2007 06:23 AM
Re: Perl with find
Actually it looks better if we print the timestamp first:
# perl -MFile::Find -le 'find(sub{print join " ",scalar localtime((stat($_))[9]),$File::Find::name if -f $_ && -M _ <= 1},".")'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 06:30 AM
тАО06-07-2007 06:30 AM
Re: Perl with find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 06:31 AM
тАО06-07-2007 06:31 AM
Re: Perl with find
Do a man perlfuncs and a man File::Find and you should be in business.
It really does you no favors to fully code the solution for you but you have enough pieces to put it together.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 06:34 AM
тАО06-07-2007 06:34 AM