Sed替换输入文件中的值

Sed替换输入文件中的值,sed,Sed,如何从输入文件导入/替换(sed)这些值 cellIdentity="461" cellIdentity="465" cellIdentity="468" cellIdentity="462" cellIdentity="466" cellIdentity="469" cellIdentity="463" cellIdentity="467" cellIdentity="460" 。并按顺序将其放入此文件,替换以下文件中的cellIdentity: sectorNumber="1" >

如何从输入文件导入/替换(sed)这些值

cellIdentity="461"
cellIdentity="465"
cellIdentity="468"
cellIdentity="462"
cellIdentity="466"
cellIdentity="469"
cellIdentity="463"
cellIdentity="467"
cellIdentity="460"
。并按顺序将其放入此文件,替换以下文件中的cellIdentity:
sectorNumber="1"

>


<Cell

cellNumber="1"

cellCreated="YES"

cellIdentity="461"

cellRange="35000"

baseBandPoolId="2"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>


<Cell

cellNumber="2"

cellCreated="YES"

cellIdentity="465"

cellRange="35000"

baseBandPoolId="2"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>


<Cell

cellNumber="3"

cellCreated="YES"

cellIdentity="468"

cellRange="35000"

baseBandPoolId="1"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>

</Sector>


<Sector

sectorNumber="2"

>


<Cell

cellNumber="1"

cellCreated="YES"

cellIdentity="462"

cellRange="35000"

baseBandPoolId="2"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>


<Cell

cellNumber="2"

cellCreated="YES"

cellIdentity="466"

cellRange="35000"

baseBandPoolId="2"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>


<Cell

cellNumber="3"

cellCreated="YES"

cellIdentity="469"

cellRange="35000"

baseBandPoolId="1"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>

</Sector>


<Sector

sectorNumber="3"

>


<Cell

cellNumber="1"

cellCreated="YES"

cellIdentity="463"

cellRange="35000"

baseBandPoolId="2"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>


<Cell

cellNumber="2"

cellCreated="YES"

cellIdentity="467"

cellRange="35000"

baseBandPoolId="2"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>


<Cell

cellNumber="3"

cellCreated="YES"

cellIdentity="460"

cellRange="35000"

baseBandPoolId="1"

numberOfTxBranches="1"

numberOfRxBranches="2"

/>

</Sector>
sectorNumber=“1”
>
我是这个项目的新手,所以任何帮助都是值得的。 我使用/bin/csh。
谢谢你的帮助,他们已经对我很好了。但我猜你想这样做:

awk 'NR==FNR{a[NR]=$(NF-1);next}/cellIdentity/{$(NF-1)=a[++i]}1' FS='"' OFS='"' inputFile bigFile
使用awk(您的输入文件格式良好,可以直接替换匹配线)


输出大文件。两者都是.xml。所以在输出中,基本上只是“cellidentity”,它们需要使用输入文件中的值进行更改。您发送的命令我在第1行附近得到了答案awk:syntax error awk:bailing out near line1@user3319356不用
awk
使用
/usr/xpg4/bin/awk
。谢谢你,它正在工作:)…还有一件事,如果我不想对你说太多的话…例如,这个输入文件是从某个更大的文本文件中获取的,我有这个(CellIdentifies),但我需要在第3、6、9行中再添加三行(相同,但最后一个数字不同)。例如“CellIdentity=4648”、“4649”、“4640”…所以最后一个数字的48,49,40一直是固定的,需要按此顺序放到第3,6,9行:)
awk 'NR==FNR{a[FNR]=$0;next}/cellIdentity/{$0=a[++i]}1' input largefile