使用sed进行XML注释时未终止的地址正则表达式

时间:2015-11-09 21:04:16

标签: regex sed

我正在尝试使用shell脚本运行以下命令:

Declare @total decimal (20,2)
Declare @EOMDate datetime

set @EOMDate = '2015-07-31'
set @total = (select sum(isnull(commission,0)) *.80 from factprograms fp 
join dimdealer dd on fp.dimDealerKey = dd.dimDealerKey 
where dd.Location like 'EU%' and fp.EOMDate = @EOMDate)

Create Table #tmp2(
  ID int primary key IDENTITY(1,1) NOT NULL,
  DealerGroupID int,
  DealerGroupName varchar (100),
  Premium decimal (20,2),
  PercentTot decimal (10,5))


insert into #tmp2
select 
DealerGroupID,
Dealergroupname, 
sum(isnull(commission,0)),
sum(isnull(commission,0)/@total)
from factprograms fp 
join dimdealer dd on fp.dimDealerKey = dd.dimDealerKey 
where dd.Location like 'EU%' and fp.EOMDate = @EOMDate
group by dd.DealerGroupID,dd.DealerGroupName
order by sum(commission) desc

select * from #tmp2 order by ID asc

Create table #tmp3(
DealerGroupName varchar(100))




drop table #tmp2,#tmp3

我收到以下错误:

sed -i -e \'s\/<!-- XML Comment 1 -->\/<!--XML Comment 2 -->\/g; s\/<!-- XML Comment 3 -->\/<!--XML Comment 4 -->\/g\'

当我尝试逃离'&lt;'时或者'!',消息只是从“char 9”变为“char 10”。当我同时逃避时,错误发生在char 11.是否还有其他角色需要逃脱?

1 个答案:

答案 0 :(得分:0)

无需转义'/

sed -i -e 's/<!-- XML Comment 1 -->/<!--XML Comment 2 -->/g; s/<!-- XML Comment 3 -->/<!--XML Comment 4 -->/g' file.xml