- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- date command output is inconsistent.
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
тАО10-27-2010 05:24 AM
тАО10-27-2010 05:24 AM
Output is correct was running date from command line but incorrect when setting an environment variable.
$ date '+%a %b %_d' --date="20 days ago"
Thu Oct 7
$ KEEP_STRING=`date '+%a %b %_d' --date="
20 days ago"`
$ echo $KEEP_STRING
Thu Oct 7
Can anyone tell me why?
and how to correct it?
Thanks
RayB
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 05:44 AM
тАО10-27-2010 05:44 AM
Solutionecho "$KEEP_STRING"
and I think you will see what you are looking for. Without the quotes, all spaces are compressed to a single space.
$ KEEP=$(date '+%a %b %_d' --date="20 days ago")
$ echo $KEEP
Thu Oct 7
$ echo "$KEEP"
Thu Oct 7
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 05:46 AM
тАО10-27-2010 05:46 AM
Re: date command output is inconsistent.
Consider the '_' characters as spaces below in my test output.
$ KEEP=$(date '+%a %b %_d' --date="20 days ago")
$ echo $KEEP
Thu_Oct_7
$ echo "$KEEP"
Thu_Oct__7
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 05:50 AM
тАО10-27-2010 05:50 AM
Re: date command output is inconsistent.
Learn something every day don't we.
I swore at that for an hour yesterday.
Thanks much.
Ray
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 05:56 AM
тАО10-27-2010 05:56 AM
Re: date command output is inconsistent.
Take care