Extract 4 digit characters

* hdisk99          U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140BA00000000  IBM MPIO FC 1750
* hdisk100         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140BB00000000  IBM MPIO FC 1750
* hdisk185         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140A000000000  IBM MPIO FC 1750
* hdisk186         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140A100000000  IBM MPIO FC 1750
* hdisk101         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140C300000000  IBM MPIO FC 1750
* hdisk102         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140C400000000  IBM MPIO FC 1750
* hdisk103         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140C500000000  IBM MPIO FC 1750
* hdisk104         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140C600000000  IBM MPIO FC 1750
* hdisk105         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140C700000000  IBM MPIO FC 1750
* hdisk106         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140C800000000  IBM MPIO FC 1750
* hdisk107         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140C900000000  IBM MPIO FC 1750
* hdisk108         U5791.001.9920BZ4-P1-C05-T1-W500507630E060C14-L401140CA00000000  IBM MPIO FC 1750
...

From the lists above, I need to pull out the first column and 4 characters from the block starting with L (i.e. L401140BA00000000).

The outputs need to be:

hdisk99 11BA
11BA

comes from L401140BA00000000
L40XX40YY......., so XXYY is the one.

For this

hdisk100  L401140BB00000000

,
it is

hdisk100  11BB

because L401140BB00000000.

Please advise.

Try

awk '{n=split($3,P,"-");print $2,substr(P[n],4,2)""substr(P[n],8,2)}' file
1 Like

Really appreciate it! Working perfect!!