I have below file:
. TAU 4236-DA 20
4236-DA - SMS
4236-DA - EMAIL
MID=4236,SC=
{AnyText}
,DABAL1=
{AnyText}
,DAEXP1=
{AnyText}
,MSISDN=
{AnyText}
»
«
. TAU 3065-DA 20
3065-DA - SMS
3065-DA - EMAIL
MID=7364,DABAL1=
{AnyText}
,DAEXP1=
{AnyText}
,MSISDN=
{AnyText}
,USEDVAL=
{AnyText}
,EXCESS=
{AnyText}
»
i want below output:
. TAU 4236 20
4236-DA - SMS
4236-DA - EMAIL
MID=4236,SC=
{AnyText}
,DABAL1=
{AnyText}
,DAEXP1=
{AnyText}
,MSISDN=
{AnyText}
»
«
. TAU 3065 20
3065-DA - SMS
3065-DA - EMAIL
MID=7364,DABAL1=
{AnyText}
,DAEXP1=
{AnyText}
,MSISDN=
{AnyText}
,USEDVAL=
{AnyText}
,EXCESS=
{AnyText}
»
[I want to remove -DA from . TAU line]. Plz help. Please also note that there are multiple strings in file in place of "-DA" which i want to remove. like "-DA", "-LA", "-MA"
You can use grouping to match TAU XXXX
like this :
sed -r 's/(TAU\s+[0-9]{4})-DA/\1 /g' data.txt
This will replace -DA
with 3 spaces when -DA
is preceding by the group (TAU\s+[0-9]{4})
or with awk
:
awk '{ print gensub(/(TAU\s+[0-9]{4})-DA/,"\\1 ","g",$0); }' data.txt