- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- prompt date string with bash
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
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
тАО07-07-2005 06:48 PM
тАО07-07-2005 06:48 PM
[objective]
Try to prompt date string that shows the date of 2 month ago from today.
I know how to make it on Solaris and Aix.
eg. dst=`env TZ=JST+1440 date +%Y%m%d`
echo $dst
This will prompt like 20050504
However, it doesn't work on HPUX... Please does sombody give me some advice.
Thank you in advance.
Solved! Go to Solution.
- Tags:
- date arithmetic
- TZ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2005 12:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2005 12:29 PM
тАО07-08-2005 12:29 PM
Re: prompt date string with bash
Use the attached caljd.sh (or search for caljd.pl; it works just the same).
#!/usr/bin/sh
DT=$(caljd.sh -y -s $(caljd.sh -p 60))
echo "60 days ago was ${DT}"
Invoke as caljd.sh -u for full usage and examples.
- Tags:
- caljd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2005 12:29 PM
тАО07-08-2005 12:29 PM
Re: prompt date string with bash
I forgot you wanted it in a script, I gave i for the command line
okay here it is
dst=`sh -c "TZ=$(date +%Z)+1440; export TZ; date '+%m%d%y'")`
echo $dst
DP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2005 04:27 PM
тАО08-23-2005 04:27 PM
Re: prompt date string with bash
Sorry for replying so late. I appliciate what you have given me advice and tips.
Now I have found why I couldn't get the target date. The reason is that the environmental variable TZ was set to "MST7MDT". I changed it to "JST-9", then the command "env TZ=JST+15 date" works!
Sorry for putting such a dum thread... I'm going to close this thread.
Best regards,
kazu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2005 04:34 PM
тАО08-23-2005 04:34 PM
Re: prompt date string with bash
# env | grep TZ
# TZ=MST7MDT
on this setting, a command "env TZ=JST+15 date" does not provide the correct answer. As above command, my timezone is JST so that TZ variable must change to JST. I changed it to JST,
After:
# env | grep TZ
# TZ=JST-9
then, the command works. The command gets yesterday's date.