- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- Languages and Scripting
- >
- Re: Script help for omni.
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:12 AM
08-05-2011 09:12 AM
I am trying to write a script wherein I want to initialize two nearest date protected tape from current date for the fields as below:
root):/home/root#omnimm -list_pool Development
Status Medium Label Location Full Protected
===============================================================================
Good [NFC777L2] Development [HP:MSL6000 Series: 25] Yes 08/06/11 - initialize via script
Good [NFC774L2] Development [HP:MSL6000 Series: 22] Yes 08/14/11
Good [NFC773L2] Development [HP:MSL6000 Series: 24] Yes 08/07/11 - initialize via script
Good [NFC784L2] Development [HP:MSL6000 Series: 23] Yes 08/13/11
Good [NFC787L2] Development [HP:MSL6000 Series: 26] No 08/14/11
I will initialize the script on friday so if the date is Aug 5 then the nearest date are 08/06 and 08/07 then these should be initialized by command "omnimm -recycle"
I got the two fields by awk and sed as below:
NFC777L2 08/06/11
NFC774L2 08/14/11
NFC773L2 08/07/11
NFC784L2 08/13/11
NFC787L2 08/14/11
I am trying to take nearest two days with respect to current date and initializ it via script but not sure how to put them in action. Any suggestion would be highly helpful.
Thanking you in advance.
Solved! Go to Solution.
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:30 AM - edited 08-05-2011 09:35 AM
08-05-2011 09:30 AM - edited 08-05-2011 09:35 AM
Re: Script help for omni.
Hi:
How about something as simple as this
# awk '{print $2,$1}' file | sort -t"/" -nk1,1 -nk2,2 | head -2
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:31 AM
08-05-2011 09:31 AM
Re: Script help for omni.
Ideally you would use a language that supports date arithmetic like perl. Then you can sort and pick the closest two.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:35 AM
08-05-2011 09:35 AM
Re: Script help for omni.
(root):/var/scripts#sort -t"/" -nk1,1 -nk2,2 list.final Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File] [-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:36 AM
08-05-2011 09:36 AM
Re: Script help for omni.
Not good in perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:40 AM
08-05-2011 09:40 AM
Re: Script help for omni.
>sort -t"/" -nk1,1 -nk2,2 list.final
It probably doesn't like the -n before the -k: sort -t"/" -k1,1n -k2,2n list.final
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:40 AM
08-05-2011 09:40 AM
Re: Script help for omni.
@kampatel wrote:(root):/var/scripts#sort -t"/" -nk1,1 -nk2,2 list.final Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File] [-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Not working
Hi (again):
For HP-UX that should be:
# awk '{print $2,$1}' file | sort -t"/" -kk1,1 -kn2,2 | head -2
...though reversing the 'k' and 'n' options works on Apple :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:42 AM
08-05-2011 09:42 AM
Re: Script help for omni.
root):/var/scripts#awk '{print $2,$1}' list.final | sort -t"/" -kk1,1 -kn2,2 | head -2
Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File]
[-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Sorry, Not working again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:44 AM - edited 08-05-2011 09:50 AM
08-05-2011 09:44 AM - edited 08-05-2011 09:50 AM
Re: Script help for omni.
>For HP-UX that should be: ... | sort -t"/" -kk1,1 -kn2,2
sort(1) says that the type is after the field start or end: field_start [ type ] [,field_end [ type ] ]
Unless you want to use the global -n: sort -t"/" -n -k1,1 -k2,2 list.final
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-05-2011 09:45 AM
08-05-2011 09:45 AM
Re: Script help for omni.
@kampatel wrote:root):/var/scripts#awk '{print $2,$1}' list.final | sort -t"/" -kk1,1 -kn2,2 | head -2
Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File]
[-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Sorry, Not working again.
Yes, and I can't type :-)
# awk '{print $2,$1}' file | sort -t"/" -kn1,1 -kn2,2 | head -2
...not '-kk' as you copied from my mangled post.
Regards!
...JRF...
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP