Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting by "stanzas"

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
I have an output of "powermt display dev=all" command (example only - there are much more hdiskpower stanzas):

Code:
Pseudo name=hdiskpower3
Symmetrix ID=000292602332
Logical device ID=08EC
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk11   FA 12fA   active  alive      0      0
   1 fscsi1                    hdisk19   FA  5fA   active  alive      0      0

Pseudo name=hdiskpower2
Symmetrix ID=000292602332
Logical device ID=08EB
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk12   FA 12fA   active  alive      0      0
   1 fscsi1                    hdisk20   FA  5fA   active  alive      0      0

Pseudo name=hdiskpower1
Symmetrix ID=000292602332
Logical device ID=08EA
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk13   FA 12fA   active  alive      0      0
   1 fscsi1                    hdisk21   FA  5fA   active  alive      0      0

How to get stanzas sorted by numbered "hdiskpowerN" to finally get output like below?

Code:
Pseudo name=hdiskpower1
Symmetrix ID=000292602332
Logical device ID=08EC
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk13   FA 12fA   active  alive      0      0
   1 fscsi1                    hdisk21   FA  5fA   active  alive      0      0

Pseudo name=hdiskpower2
Symmetrix ID=000292602332
Logical device ID=08EB
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk12   FA 12fA   active  alive      0      0
   1 fscsi1                    hdisk20   FA  5fA   active  alive      0      0

Pseudo name=hdiskpower3
Symmetrix ID=000292602332
Logical device ID=08EA
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk11   FA 12fA   active  alive      0      0
   1 fscsi1                    hdisk19   FA  5fA   active  alive      0      0

 
Hi

The easiest is using asorti(), a GNU AWK extension :
Code:
powermt display dev=all | awk -F= '$1=="Pseudo name"{k=$2}{d[k]=d[k]$0ORS}END{asorti(d,s);for(k in s)print d[s[k]]}'
If your hdiskpowers are numbered sequentially from 1 to N, without gaps, a simple loop will be enough :
Code:
powermt display dev=all | awk -F= '$1=="Pseudo name"{k=$2}{d[k]=d[k]$0ORS}END{for(k=1;"hdiskpower"k in d;k++)print d["hdiskpower"k]}'
If none of those works, will think to something else.

Feherke.
 
With basic scripting (no fancy GNU stuff ;-)):

on AIX:
[tt]
for disk in $(lsdev -type disk -F name|grep hdiskpower|sort)
do
powermt display dev=${disk}
echo
done
[/tt]

On other unix find some other way to get hdiskpower device names in a sorted list.


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top