awk or sed script to remove strings

Below am trying to separate FA-7A:1, In output file it should display 7A 1

Command am using

Gives same output as below format:
22B7 10000000c9720873   0
22B7 10000000c95d5d8b   0
22BB 10000000c97843a2   0
22BB 10000000c975adbd   0
Not showing FA ports as required format output:
 
01FB 10000000c97843a2   8C  0
01FB 10000000c96fb279   9C  0
22AF 10000000c97843a2   8C  0
22AF 10000000c975adbd   8C  0
perl -alne '{if(/^\d/) {$val=$F[0];$F[3]=~s/.*?-(\w+):(\d)/$1 $2/;print "$F[0] $F[1] $F[3]";} else{ if(/^100/){$F[2]=~s/.*?-(\w+):(\d)/$1 $2/;print "$val $F[0] $F[2]";next;}}}'

I thought this command in your previous post had helped you..

1 Like

Could you please show real input, and your exact desired output. It looks like you have a lot of code you do not need, but we cannot tell.

Telling us what it does wrong helps no one.

Hope this is much clear, After removing unwanted lines from file below is the input, I need the below Red values also in Output with space between 7D 0

3EFC    10000000c97239cf  FIBRE  FA7D:0
        10000000c96fc9f1  FIBRE  FA10D:0
 
3EFD    10000000c97239cf  FIBRE  FA7D:0
        10000000c96fc9f1  FIBRE  FA10D:0
 
3EFE    10000000c97239cf  FIBRE  FA7D:0
        10000000c96fc9f1  FIBRE  FA10D:0
Output am getting:
3EFC 10000000c97239cf   0
3EFC 10000000c96fc9f1   0
3EFD 10000000c97239cf   0
3EFD 10000000c96fc9f1   0
3EFE 10000000c97239cf   0
3EFE 10000000c96fc9f1   0

using infile:

3EFC    10000000c97239cf  FIBRE  FA7D:0
        10000000c96fc9f1  FIBRE  FA10D:0
3EFD    10000000c97239cf  FIBRE  FA7D:0
        10000000c96fc9f1  FIBRE  FA10D:0
3EFE    10000000c97239cf  FIBRE  FA7D:0
        10000000c96fc9f1  FIBRE  FA10D:0

and:

awk '/^ *$/{next;} length($1)!=4 { $0=l " " $0; } {l=$1 ; gsub("[:-]"," "); $3=""; sub("^FA","",$4)} 1' infile

output:

3EFC 10000000c97239cf  7D 0
3EFC 10000000c96fc9f1  10D 0
3EFD 10000000c97239cf  7D 0
3EFD 10000000c96fc9f1  10D 0
3EFE 10000000c97239cf  7D 0
3EFE 10000000c96fc9f1  10D 0
1 Like

rdrtx1,

Thanks a Lot. Gives exact required output.

Regards.