- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Column's format display challenge (scripting)
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
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.