- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to get the most recent updated file in ...
Operating System - HP-UX
1752815
Members
6333
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
- 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
- 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
- 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
- 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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP