- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Column's format display challenge (scripting)
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
тАО05-25-2009 11:16 PM
тАО05-25-2009 11:16 PM
In this case the followin string must be caught in a variable:
2 9 16 23 30
The problem here are the left lead space characters. Some hint or solution for this?
Rgds.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2009 11:29 PM
тАО05-25-2009 11:29 PM
Re: Column's format display challenge (scripting)
cal 04 2009 |tail +3 |cut -c13-14
2
9
16
23
30
Done.
BR,
Cedrick Gaillard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2009 12:52 AM
тАО05-26-2009 12:52 AM
Re: Column's format display challenge (scripting)
awk can ignore those:
awk '
NR == 3 {print $(NF-2)} # adjust for short week
NR > 3 {print $5}' # adjust for short last week
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2009 03:59 AM
тАО05-26-2009 03:59 AM
Re: Column's format display challenge (scripting)
you can do like this also
cal 04 2009 |tail +3|cut -c13-14 |awk '{ printf " " $0 }'
example
[user2@rspc521 user2]$ cal 04 2009 |tail +3|cut -c13-14 |awk '{ printf " " $0 }'
2 9 16 23 30 [user2@rspc521 user2]$
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2009 04:12 AM
тАО05-26-2009 04:12 AM
Solution@ Suraj: The problem with using 'cut' (or something like 'substr' in 'awk' is that you rely on column widths that are potentially non-portable. For instance, your solution works in HP-UX, giving Jose the Thursday dates. If run in AIX, however, you return Wednesday dates --- not nice.
Dennis's solution works nicely:
# DAYS=$(cal 04 2009|awk 'NR==3 {print $(NF-2)};NR>3 {print $5}')
# echo ${DAYS}
2 9 16 23 30
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2009 11:09 PM
тАО05-28-2009 11:09 PM
Re: Column's format display challenge (scripting)
James, a state of the art solution!
Rgds.