我有一个名为 的大文件res.dat
,其中包含我需要修改的某些数据。所有数据都在一行上。
例如:
L1TRAIN="200" NEEDL2="14" L2TRAIN="300" NEEDL3="16" L3TRAIN="400" NEEDL4="99" L4TRAIN="600" NEEDL5="99" L5TRAIN="900" DELAY="60" COOLTIME="0" KORNAME="화염풍" SKILLTYPE="0" TOOLTIP="A defensive spell that allows you to push away enemies of lower level. This spell has a fixed chance for success. The range of the spell and chance of success increase with training." /><VALUE MAGID="9" MAGNAME="Lavastrike" TYPE="0" EFFECTTYPE="5" EFFECT="7" SPELL="11" POWER="14" MAXPOWER="18" DEFSPELL="15" DEFPOWER="12" DEFMAXPOWER="16" JOB="1" PHASE="0" NEEDL1="20" L1TRAIN="500" NEEDL2="22" L2TRAIN="600" NEEDL3="24" L3TRAIN="700" NEEDL4="99" L4TRAIN="900" NEEDL5="99" L5TRAIN="1200" DELAY="80" COOLTIME="0" KORNAME="염사장" SKILLTYPE="0" TOOLTIP="A spell that shoots out line of fire along the ground, damaging all enemies caught within the fire. Its damage increases with training." /><VALUE MAGID="10" MAGNAME="LightningBeam" TYPE="2" EFFECTTYPE="6" EFFECT="8" SPELL="12" POWER="14" MAXPOWER="14" DEFSPELL="15" DEFPOWER="12" DEFMAXPOWER="16" JOB="1" PHASE="0" NEEDL1="21" L1TRAIN="500" NEEDL2="23" L2TRAIN="600" NEEDL3="25" L3TRAIN="700" NEEDL4="99" L4TRAIN="900" NEEDL5="99" L5TRAIN="1200" DELAY="80" COOLTIME="0" KORNAME="뢰인장" SKILLTYPE="0"
我需要运行一个脚本,查找 、 、 、 和 的双引号内的数据,L1TRAIN
并将L2TRAIN
它们L3TRAIN
全部L4TRAIN
更新L5TRAIN
为 L1TRAIN="100" L2TRAIN="200" L3TRAIN="300" L4TRAIN="400" L5TRAIN="500"
存在需要修改的负载,所有数据都在一行上。
该示例的输出应该是:
L1TRAIN="100" NEEDL2="14" L2TRAIN="200" NEEDL3="16" L3TRAIN="300" NEEDL4="99" L4TRAIN="400" NEEDL5="99" L5TRAIN="500" DELAY="60" COOLTIME="0" KORNAME="화염풍" SKILLTYPE="0" TOOLTIP="A defensive spell that allows you to push away enemies of lower level. This spell has a fixed chance for success. The range of the spell and chance of success increase with training." /><VALUE MAGID="9" MAGNAME="Lavastrike" TYPE="0" EFFECTTYPE="5" EFFECT="7" SPELL="11" POWER="14" MAXPOWER="18" DEFSPELL="15" DEFPOWER="12" DEFMAXPOWER="16" JOB="1" PHASE="0" NEEDL1="20" L1TRAIN="100" NEEDL2="22" L2TRAIN="200" NEEDL3="24" L3TRAIN="300" NEEDL4="99" L4TRAIN="400" NEEDL5="99" L5TRAIN="500" DELAY="80" COOLTIME="0" KORNAME="염사장" SKILLTYPE="0" TOOLTIP="A spell that shoots out line of fire along the ground, damaging all enemies caught within the fire. Its damage increases with training." /><VALUE MAGID="10" MAGNAME="LightningBeam" TYPE="2" EFFECTTYPE="6" EFFECT="8" SPELL="12" POWER="14" MAXPOWER="14" DEFSPELL="15" DEFPOWER="12" DEFMAXPOWER="16" JOB="1" PHASE="0" NEEDL1="21" L1TRAIN="100" NEEDL2="23" L2TRAIN="200" NEEDL3="25" L3TRAIN="300" NEEDL4="99" L4TRAIN="400" NEEDL5="99" L5TRAIN="500" DELAY="80" COOLTIME="0" KORNAME="뢰인장" SKILLTYPE="0"
答案1
这是一种方法sed
:
sed 's/\(L\([1-5]\)TRAIN="\)[^"]*/\1\200/g' res.dat
这使用分组和反向引用,替换任何出现的
Ln火车=“anything_ except_double_quote
和
Ln训练=n00
在哪里n1
是和之间的数字5
。