HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need to append previous day's date to a filename
Operating System - HP-UX
1833514
Members
3359
Online
110061
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
Forums
Discussions
Discussions
Discussions
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
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
03-15-2002 12:31 PM
03-15-2002 12:31 PM
Hello,
I am trying to append a date suffix to a log filename so that I can start a new log. I would like the format to be.yyyy_mm_dd. Now for the hard part. The script runs Monday through Friday. On Mondays, I would like to use the previous Friday's date and on the other weekdays the previous day's date. Trying to get this thing to work is driving me crazy. Please help.
Thanks, Bob
I am trying to append a date suffix to a log filename so that I can start a new log. I would like the format to be
Thanks, Bob
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2002 12:39 PM
03-15-2002 12:39 PM
Solution
Hi Bob:
I can get you going in a couple of lines of code. How about this:
FILENAME="xxxx" # your filename
LOGNAME="${FILENAME}.$(caljd.sh -y -S '_' $(caljd.sh -p 1 -x 0 -x 6))"
Believe it or not, you are done. The inner caljd.sh says skip to the previous day (-p 1); if that falls on a Sunday (-x 0) or Saturday (-x 7) keep going backwards. The outer caljs.sh says take the argment and return a calendar date in yyyy mm dd (-y) order and use '_' (-S '_') as a separator.
Caljd.sh is my date hammer; now where's your date nail?
Regards, Clay
I can get you going in a couple of lines of code. How about this:
FILENAME="xxxx" # your filename
LOGNAME="${FILENAME}.$(caljd.sh -y -S '_' $(caljd.sh -p 1 -x 0 -x 6))"
Believe it or not, you are done. The inner caljd.sh says skip to the previous day (-p 1); if that falls on a Sunday (-x 0) or Saturday (-x 7) keep going backwards. The outer caljs.sh says take the argment and return a calendar date in yyyy mm dd (-y) order and use '_' (-S '_') as a separator.
Caljd.sh is my date hammer; now where's your date nail?
Regards, Clay
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2002 12:42 PM
03-15-2002 12:42 PM
Re: Need to append previous day's date to a filename
Ooops, the code is right but the explanation is wrong. -x 6 skips Saturdays. Sorry about that.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2002 01:02 PM
03-15-2002 01:02 PM
Re: Need to append previous day's date to a filename
Wow! Perfect!!!
Clay, the funny thing is that I already had a copy of your caljd.sh script. You used it in an Omniback copy script. I just didn't know what it did. I just looked at it again and I have no idea how it works but it works!!
Thanks, Bob
Clay, the funny thing is that I already had a copy of your caljd.sh script. You used it in an Omniback copy script. I just didn't know what it did. I just looked at it again and I have no idea how it works but it works!!
Thanks, Bob
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.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP