1

I have the following text file that I want to manipulate

add_journal_volume group="RPCG_VLS_PSALTUXP201" copy="TW_PROD_VLS" uid="60,06,01,60,01,d0,40,00,37,1e,85,5e,17,9c,ea,11" uid_hash="0xfd81565b74f160c3"  -f;
add_replication_volume group="RPCG_VLS_PSALTUXP201" copy="VNX057_CRR_PSALTUXP201" replication_set="RSet0" uid="60,06,01,60,0e,60,3c,00,16,f5,56,7f,02,d8,e8,11" uid_hash="0xd7c77496f2520fbc"  -f;
add_replication_volume group="RPCG_VLS_PSALTUXP201" copy="VNX057_CRR_PSALTUXP201" replication_set="RSet1" uid="60,06,01,60,0e,60,3c,00,18,f5,56,7f,02,d8,e8,11" uid_hash="0x62d865f2be9ff409"  -f;

Basically I just want to return as column delimited text using ";"

RPCG_VLS_PSALTUXP201;TW_PROD_VLS;;60,06,01,60,01,d0,40,00,37,1e,85,5e,17,9c,ea,11
RPCG_VLS_PSALTUXP201;VNX057_CRR_PSALTUXP201;RSet0;60,06,01,60,0e,60,3c,00,16,f5,56,7f,02,d8,e8,11
RPCG_VLS_PSALTUXP201;VNX057_CRR_PSALTUXP201;RSet1;60,06,01,60,0e,60,3c,00,18,f5,56,7f,02,d8,e8,11

The tricky part is those add_journal_volume line there is no replication_set so in that case I just want to leave it blank.

2

With perl:

perl -lne 'my %f; $f{$1} = $2 while /(\w+)="(.*?)"/g;
           print join ";", @f{qw(group copy replication_set uid uid_hash)}'
| improve this answer | |

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.