- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Need help on date variable
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
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-20-2009 11:03 PM
10-20-2009 11:03 PM
Need help on date variable
Need your help.I need to get the date from the second line of a file
[devuser@vfabuser ~]$ head -n2 ETCTRN4010000A.092309.023021001.txt | tail -n1
02,3009483,121000248,1,090922,,,/
[devuser@vfabuser ~]$
If you see above, I need 090922 stored to a variable as ‘22-SEP-2009’
Please help.
Thanks
Gaby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2009 11:51 PM
10-20-2009 11:51 PM
Re: Need help on date variable
| cut -d',' -f5
Regards,
Goran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2009 03:22 PM
10-21-2009 03:22 PM
Re: Need help on date variable
# Set var for test below
$ dt="090922"
You can convert the display format using 'date', e.g.:
$ date -d"${dt}" +"%d-%h-%Y"
22-Sep-2009
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2009 09:17 PM
10-21-2009 09:17 PM
Re: Need help on date variable
info date
will give you more details how to use this with examples (or info coreutils -> date).
Regards,
Goran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2009 12:49 AM
10-22-2009 12:49 AM
Re: Need help on date variable
You can write a small script and use a temporary variable to hold the digits, but you can also do this in one line:
dt=$(date -d $(head -n2 ETCTRN4010000A.092309.023021001.txt |tail -n1 |cut -d ',' -f5) +"%d-%h-%Y")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2009 08:55 PM
10-23-2009 08:55 PM
Re: Need help on date variable
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1380285