1

Command on AIX is:

[root@hx042:/home/user1]$ lqueryvg -Atp hdiskpower13
0516-1396 lqueryvg: The physical volume hdiskpower13, was not found in the system database. 
Max LVs:        256 
PP Size:        30 
Free PPs:       0 
LV count:       3 
PV count:       3 
Total VGDAs:    3 
Conc Allowed:   0 
MAX PPs per PV: 1016 
MAX PVs:        32 
Quorum (disk):  1 
Quorum (dd):    ??????? 
Auto Varyon ?:  1 
Conc Autovaryon 0 
Varied on Conc: 0
Logical:        00f62b5c00004c000000014de7f073b1.1   prekod 1  
                00f62b5c00004c000000014de7f073b1.2   prekre 1  
                00f62b5c00004c000000014de7f073b1.3   prekcf 1
Physical:       00f62b5ceb80c074                1   0  
                00f62b5ceb76311b                1   0  
                00f62b5ceb790075                1   0   
Total PPs:      309 
LTG size:       128 
HOT SPARE:      0 
AUTO SYNC:      0 
VG PERMISSION:  0 
SNAPSHOT VG:    0 
IS_PRIMARY VG:  0 
PSNFSTPP:       4352 
VARYON MODE:    ??????? 
VG Type:        0 
Max PPs:        32512
Mirror Pool Str n 
Sys Mgt Mode:   ??????? 
VG Reserved:    ??????? 
PV RESTRICTION: ??????? 
Infinite Retry: 2 
Varyon State:   0 
Disk Block Size 512

I need only these values out:

prekod
prekre
prekcf

I tried:

[root@hx042:/home/user1]$ lqueryvg -Atp hdiskpower13|sed -n -e '/Logical/,/Physical/ p'                
0516-1396 lqueryvg: The physical volume hdiskpower13, was not found in the
system database.
Logical:        00f62b5c00004c000000014de7f073b1.1   prekod 1  
                00f62b5c00004c000000014de7f073b1.2   prekre 1  
                00f62b5c00004c000000014de7f073b1.3   prekcf 1  
Physical:       00f62b5ceb80c074                1   0  

and now I'm stuck because there is Logical in same line as first value I need, also there is this unavoidable error message which is not useful at all at this point which I also don't need.

  • to add: command lqueryvg -Ap hdiskpower13 give same output but without value names – user165435 Apr 13 '16 at 13:32
0

There's probably a smarter way to do this all in awk, but Guido's on the right track with sending stderr to /dev/null to get rid of the 0516-1396 message. Here's a pipeline that uses sed to print just the lines between "Logical:" and "Physical", then uses sed again to delete the trailing "Physical" line and to delete the "Logical:" text before then using awk to print the 2nd column:

lqueryvg -Atp hdiskpower13 | \
  sed -n '/^Logical:/,/^Physical:/ p' | \
  sed '/^Physical:/d; s/^Logical://' | \
  awk '{print $2}'

Here's an all-awk solution that is still pretty brute-force:

lqueryvg -Atp hdiskpower13 | \
  awk '/^Logical:/,/^Physical/ { 
    if (! /^Physical:/) { 
      gsub("Logical:", "", $0); 
      print $2 }}'
  • You're right… no -E option in AIX 😒 – Guido Apr 13 '16 at 19:44
  • after playing around with lqueryvg a bit more, I would recommend: lqueryvg -Lp hdiskpower13 | awk '{print $2}' – Jeff Schaller Apr 13 '16 at 20:23
0
for i in prekod prekcf prekre; do lqueryvg -Atp hdiskpower13 | grep $i; done | sed 's/Logical://g' | sed 's/^[ \t]*//;s/[ \t]*$//' | awk '{print $2" "$3}'
0

cut would also work I think, and it would be a little simpler, assuming the output is always going to be similar. For the specific output you quoted above:

grep 'prek*' |cut -w -f3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.