Re: Help with scripting issue ... (406 Views)
Reply
Super Advisor
MikeL_4
Posts: 958
Registered: ‎05-05-2002
Message 1 of 5 (433 Views)
Accepted Solution

Help with scripting issue ...

I am issuing a setboot command to capture my Primary and Secondary boot devices which I am interested in the following lines:

 

Primary bootpath : 0/0/0/2/0/0/0.0x0.0x1010000c0000000 (/dev/rdisk/disk2)
HA Alternate bootpath : 0/0/0/2/0/0/0.0x0.0x1000000c0000000 (/dev/rdisk/disk3)

 

From this is there a way in a script to pick out just the 'disk2' and 'disk3' from each line ??

 

 

Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 5 (431 Views)

Re: Help with scripting issue ...

Hi:

 

One quick way:

 

# setboot | perl -nle 'm{rdisk/(\w+)} and print $1'

 Regards!

 

...JRF...

Super Advisor
MikeL_4
Posts: 958
Registered: ‎05-05-2002
Message 3 of 5 (422 Views)

Re: Help with scripting issue ...

nks you, I never think about using perl....

Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 4 of 5 (418 Views)

Re: Help with scripting issue ...

Hi (again):


MikeL_4 wrote:

nks you, I never think about using perl....


And I *always* think Perl first :-)

 

To assign kudos, you need to explictly toggle them.  Marking a post as "solved" [which is a very appropriate thing to do] is a *separate* action.

 

Regards!

 

...JRF...

Acclaimed Contributor
Dennis Handly
Posts: 25,071
Registered: ‎03-06-2006
Message 5 of 5 (406 Views)

Re: Help with scripting issue ...

[ Edited ]

>I never think about using perl

 

You could also use sed to select the token between "rdisk/" and ")".  Something like:

sed -e '/rdisk/ s:.*rdisk/\([^)]*\)):\1:' file

 

Actually some slight changes:

sed -n -e '/rdisk/ { s:.*rdisk/\([^)]*\)):\1:; p; }' file

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.