我正在尝试填充一些 XML 字段,以便让自己在我正在执行的大量手动数据输入中占得先机。
我正在尝试使用正则表达式和 2 个平面文件来转换这样的文本:
EA10A3
进入这个:
<nodevice id="EA10A3" seq=" " />
以下是 sed 发生的情况:
~/Tickets/RWSP-11422 > cat locations.txt
EA10A1
EA10A2
EA10A3
~/Tickets/RWSP-11422 > cat platform
<nodevice id="PPPPPP" seq=" " />
~/Tickets/RWSP-11422 > while read i; do cat platform | sed "s/PPPPPP/$i/g"; done <locations.txt
" seq=" " />ice id="EA10A1
" seq=" " />ice id="EA10A2
" seq=" " />ice id="EA10A3
Perl 也是如此:
~/Tickets/RWSP-11422 > while read i; do cat platform | perl -wpl -e "s/PPPPPP/$i/g"; done < locations.txt
" seq=" " />ice id="EA10A1
" seq=" " />ice id="EA10A2
" seq=" " />ice id="EA10A3
为什么我越来越
" seq=" " />ice id="EA10A1
代替
<nodevice id="EA10A1" seq=" " />
?
我怎样才能做到这一点?