我有一个 120k 的文本,类似于下面的文本,我想在以 结尾的行末尾添加 " (引号)lr:
。您能告诉我如何使用 sed 或 awk 来做到这一点吗?
HSS-ServiceProfile=consumer_mmtel_d426s6
hss-Trigger2ApplicationServers="42601:sip\\:d426s6mtasorig.routingcore.imsw..it;call=orig;lr:
hss-Trigger2ApplicationServers="42603:sip\\:d426s6mtasorig.routingcore.imsw..it;call=orig;lr:
hss-Trigger2ApplicationServers="42605:sip\\:d426s6mtastermrg.routingcore.imsw..it;call=term;lr:
hss-Trigger2ApplicationServers="42607:sip\\:d426s6mtastermnr.routingcore.imsw..it;call=term;lr:
hss-DefaultApplicationServer="sip:d426s6mtasorig.routingcore.imsw..it;lr"
hss-DefaultASHandling="SESSION_CONTINUED"
hss-DsaiCapability=false
提交-s up
HSS-ServiceProfile=Pk3_mmtel_d426s1
hss-Trigger2ApplicationServers="42601:sip\\:d426s1mtasorig.routingcore.imsw..it;call=orig;lr:SESSION_CONTINUED"
hss-Trigger2ApplicationServers="42603:sip\\:d426s1mtasorig.routingcore.imsw..it;call=orig;lr:SESSION_TERMINATED"
hss-Trigger2ApplicationServers="42605:sip\\:d426s1mtastermrg.routingcore.imsw..it;call=term;lr:SESSION_TERMINATED"
hss-Trigger2ApplicationServers="42607:sip\\:d426s1mtastermnr.routingcore.imsw..it;call=term;lr:SESSION_TERMINATED"
hss-DefaultApplicationServer="sip:d426s1mtasorig.routingcore.imsw..it;lr"
hss-DefaultASHandling="SESSION_TERMINATED"
hss-DsaiCapability=false
答案1
lr:
告诉 sed 将行尾替换为自身加双引号:
sed -e 's/lr:$/&"/'
# ^ ^
# | |
# End of |
# line The whole
# matching part