- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- help find and compress
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
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
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
10-16-2009 02:31 AM
10-16-2009 02:31 AM
please help me with this
I need to take file from a path /home/abc/
· Get the date from the file example 20091008 from MasterIndex20091008_2.xml
· Then check if the date is 7days old or it is a month end(last day of month) or it is last day(Friday)of a week.
· If not above, then that file should be zipped .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2009 04:27 AM
10-16-2009 04:27 AM
SolutionI'll give you some pointers.
Use 'find /home/abc -type f -mtime +7' to find files that are 7-days or older. If you truly want only 7-days, drop the "+".
You could use regular expressions to snip out the date from your filename or simply use 'cut' if you have a format that suggests what to isolate.
Dennis offered a nice 'awk' solution to a question you asked before. Of course, you very rearely assign points so no one knows if his solution enlightened you:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1336329
What's also noteworthy is that he used the 'cal' command to determine if the date was the last of the month --- exactly one of your requirements here.
For resolving whether or not a particular date is a Friday, you could test for a value of _five (5) as returned by:
# perl -MTime::Local -wle 'print +(localtime(timelocal(0,0,0,$ARGV[1],$ARGV[0]-1,$ARGV[2]-1900)))[6]' MM DD YYYY
...where you pass the MM, DD and YYYY values that you want to assess.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2009 05:07 AM
10-16-2009 05:07 AM
Re: help find and compress
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2009 05:26 AM
10-16-2009 05:26 AM
Re: help find and compress
I dont have perl compiler on my system. Can you suggest any approach using shel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2009 06:02 AM
10-16-2009 06:02 AM
Re: help find and compress
> I dont have perl compiler on my system. Can you suggest any approach using shel.
You should have Perl of some version even on very old HP-UX systems. That aside, you could use Clay's 'caljd' script to perform a multitude of manipulations. You can fetch a version from Merijn's site:
http://mirrors.develooper.com/hpux/
# ./caljd -w 10 16 2009
5
...the value of 5 returned signifies a Friday.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2009 06:19 AM
10-16-2009 06:19 AM
Re: help find and compress
Need another clarification on 7 days old file.
When i fetch a date (yyyymmdd) from a file name (this will be diferent from date attached with the file), is it possible to find if that yyyymmdd is 7 or more old days old considering only weekdays?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2009 07:01 AM
10-16-2009 07:01 AM
Re: help find and compress
> When i fetch a date (yyyymmdd) from a file name (this will be diferent from date attached with the file), is it possible to find if that yyyymmdd is 7 or more old days old considering only weekdays?
If I understand correctly, then the following applies:
'find()' has no concept of weekends. Time is measured in epoch seconds and when 'find()'s '-mtime' is used the units are the number of seconds in a 24-hour period measured from the file's modification time. For example, given that today is Oct 16, seven days ago it was Oct 9 and:
# find /path -type f -mtime 7
...will return files that were last modified Oct 8 or Oct 9 since the rule is that 'find' will return our files when the modification time subtracted from the initialization time is n-1 to n multiples of 24-hours. This is described in the manpages.
I suppose that you could "adjust" your criteria using nine (9) instead of (7) days as your 'find' window.
Regards!
...JRF...