Shell script - help needed

I want to take out the Z1 value from the lscfg outpu and use the below command to get it

 lscfg -vl hdisk0 | grep "Device Specific.(Z1)"  | awk -F. '{print $NF}'
# lscfg -vpl hdisk0
.
.
Device Specific.(Z0)........0000063268181002
Device Specific.(Z1)........020064a
.

And it works, some times the lscfg output will be like this.

#lscfg -vpl hdisk0
.
.
Device Specific.(Z1)........020064a 051a .........
.
.

Can you please help me to get the "020064a 051a" value for the below lscfg output?

Would that work?

lscfg -vl hdisk0 | perl -nle '/Z1\)\.+(\w+\s?\w*)/ and print $1'

Output:

020064a
020064a 051a
1 Like

Hi Aia, That works, thanks! :slight_smile: