Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
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