Simple AWK cleanup/questions AIX

I have an unfortunate need to redo a bunch of disk settings on a VIOS on AIX, so I was putting together a quick script to scrub everything it has, make the changes, and then put the mappings back. It works, I just am trying to get my awk a bit more up-to-snuff and wanted to know the proper way to conjoin my awk statements

Initial Output:

$ lsmap -vadapter vhost3
vhost3          XXXXX.XXX.XXXXXXXX-XX-XXX                     0x00000007

VTD                   xxxx_datavg1
Status                Available
LUN                   0x8400000000000000
Backing device        hdisk41
Physloc               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Mirrored              false

VTD                   xxxx_rootvg1
Status                Available
LUN                   0x8500000000000000
Backing device        hdisk44
Physloc               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Mirrored              false

VTD                   xxxx_rootvg2
Status                Available
LUN                   0x8600000000000000
Backing device        hdisk45
Physloc               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Mirrored              false

What I have (and desired output)

$ lsmap -vadapter vhost3| awk '/^VTD|^Backing/' | awk 'ORS=NR%2?FS:RS'| awk '{print $2,$5}'
xxxx_datavg1 hdisk41
xxxx_rootvg1 hdisk44
xxxx_rootvg2 hdisk45

Learning awk hack and slash as I go, and I'm sure missing important fundamentals, but would appreciate the help on cleaning this up into a coherent single awk call.

awk '/VTD/{a=$2}/Backing/{ print a,$NF}' 

Thanks so much mate, in case anyone else wants the oneliner (I'm just making it into functions and going to put it in the profiles)

Recreate:

HOST_ID=3 && lsmap -vadapter vhost${VHOST_ID} | awk -v vhid="$VHOST_ID" '/VTD/{a=$2}/Backing/{print "mkvdev -vdev "$NF" -vtd "a" -vadapter vhost"vhid}'

Remove:

VHOST_ID=3 && lsmap -vadapter vhost${VHOST_ID} | awk -v vhid="$VHOST_ID" '/VTD/{print "rmvdev -vdev "$NF}'

Want these to scream so I never have them automagically run on me, but that's the basics if anyone else needed :slight_smile: