Skip to ContentSkip to Footer
Start of content
- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- General
- >
- Re: script to get the most recent updated file in ...
General
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
Go to solution
Topic Options
- 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
- Email to a Friend
- Report Inappropriate Content
01-27-2006 01:14 AM
01-27-2006 01:14 AM
Re: script to get the most recent updated file in a dir-tree
Hi Peter:
While I didn't use perl's Find module, but rather called the system's 'find' to begin the work, the approach we both took is similar.
I've attached a better version of what I first wrote. It's not biased -- it reports all files with the same, most recent timestamp.
See the attached!
Run as:
# ./mfile dirname
You can specify multiple directories as arguments, too.
Regards!
...JRF...
While I didn't use perl's Find module, but rather called the system's 'find' to begin the work, the approach we both took is similar.
I've attached a better version of what I first wrote. It's not biased -- it reports all files with the same, most recent timestamp.
See the attached!
Run as:
# ./mfile dirname
You can specify multiple directories as arguments, too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-27-2006 01:32 AM
01-27-2006 01:32 AM
Re: script to get the most recent updated file in a dir-tree
JRF,
This looks great. I am already using your first script because that fits already my requirements. I am extending it with other checks using the output of the stat function in an array. This saves me running trough the tree structure multiple times, which I should have done without a perl solution.
(I needed to check also the data on permissions/group ownerships etc.., that is now easy with this perl script.)
Many thanks for your help in putting me in the right direction.
I leave this thread open til Monday to see if anyone can think of some other solution. It's always nice to see how many people can come up with different solutions with the same result.
Peter
This looks great. I am already using your first script because that fits already my requirements. I am extending it with other checks using the output of the stat function in an array. This saves me running trough the tree structure multiple times, which I should have done without a perl solution.
(I needed to check also the data on permissions/group ownerships etc.., that is now easy with this perl script.)
Many thanks for your help in putting me in the right direction.
I leave this thread open til Monday to see if anyone can think of some other solution. It's always nice to see how many people can come up with different solutions with the same result.
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-27-2006 02:27 AM
01-27-2006 02:27 AM
Re: script to get the most recent updated file in a dir-tree
Peter,
that your Perl compiler complained about undeclared variables $latest and $file,
and moaned about an undefined sub "our"
indicates to me that you run it with a very dated Perl installation.
Actually, the our type was introduced with Perl 5.6 to replace the somewhat awkward "use vars" pragma.
I suggest you update your Perl
(if that is possible for you).
What is your Perl version?
(run "perl -v", or "perl -V")
Had I included the line
require '5.006';
then your Perl compiler should have exitetd with a meaningful message.
Besides, it was silly of me to declare the variables as our.
Just substitue the "our" with "my",
and it should execute with your Perl.
Or in fact you could get rid of any variable declaration at all, and remove the line with the "use strict" pragma.
For such a tiny bit of code its perfectly in order to have all variables implicitly declared as package globals (same as prepending an "our" at declaration with a Perl >= 5.6)
This is what the compiler silently assumes.
But for any Perl code extending a hundred lines or using different namespaces (viz. packages/modules) it should be mandatory to "use strict".
Apropos, if you strip off the -f test
then every kind of file (in the Unix sense) will be taken into account.
that your Perl compiler complained about undeclared variables $latest and $file,
and moaned about an undefined sub "our"
indicates to me that you run it with a very dated Perl installation.
Actually, the our type was introduced with Perl 5.6 to replace the somewhat awkward "use vars" pragma.
I suggest you update your Perl
(if that is possible for you).
What is your Perl version?
(run "perl -v", or "perl -V")
Had I included the line
require '5.006';
then your Perl compiler should have exitetd with a meaningful message.
Besides, it was silly of me to declare the variables as our.
Just substitue the "our" with "my",
and it should execute with your Perl.
Or in fact you could get rid of any variable declaration at all, and remove the line with the "use strict" pragma.
For such a tiny bit of code its perfectly in order to have all variables implicitly declared as package globals (same as prepending an "our" at declaration with a Perl >= 5.6)
This is what the compiler silently assumes.
But for any Perl code extending a hundred lines or using different namespaces (viz. packages/modules) it should be mandatory to "use strict".
Apropos, if you strip off the -f test
then every kind of file (in the Unix sense) will be taken into account.
Madness, thy name is system administration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-30-2006 08:19 PM
01-30-2006 08:19 PM
Re: script to get the most recent updated file in a dir-tree
All,
Thanks for the instructive input you all gave me.
Cheers,
Peter
Thanks for the instructive input you all gave me.
Cheers,
Peter
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
End of content
United States
Hewlett Packard Enterprise International
Communities
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP