Operating System - HP-UX
1751687 Members
4296 Online
108781 Solutions
New Discussion

Help with scripting issue ...

 
SOLVED
Go to solution
MikeL_4
Super Advisor

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 ??

 

 

4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: Help with scripting issue ...

Hi:

 

One quick way:

 

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

 Regards!

 

...JRF...

MikeL_4
Super Advisor

Re: Help with scripting issue ...

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

James R. Ferguson
Acclaimed Contributor

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...

Dennis Handly
Acclaimed Contributor

Re: Help with scripting issue ...

>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