求大神,怎么用LINUX在指定的一行添加其他文件内容
答案:3 悬赏:80
解决时间 2021-02-12 07:27
- 提问者网友:唤魂
- 2021-02-11 23:50
求大神,怎么用LINUX在指定的一行添加其他文件内容
最佳答案
- 二级知识专家网友:桃花别处起长歌
- 2021-02-12 00:51
1、放在后面比较简单
sed -i '/\<\/bean\>/r datasource.txt' global.datasource.xml
2、放在前面的话,得先计算出行数,然后计算出前一行
#!/bin/bash
row1=`sed -n '/\<\/bean\>/=' global.datasource.xml`
row2=`expr ${row1} - 1`
sed -i "$row2 r datasource.txt" global.datasource.xml
3、楼上的方法也行
sed -i "/<\/bean>/i $(cat datasource.txt)" global.datasource.xml
sed -i '/\<\/bean\>/r datasource.txt' global.datasource.xml
2、放在前面的话,得先计算出行数,然后计算出前一行
#!/bin/bash
row1=`sed -n '/\<\/bean\>/=' global.datasource.xml`
row2=`expr ${row1} - 1`
sed -i "$row2 r datasource.txt" global.datasource.xml
3、楼上的方法也行
sed -i "/<\/bean>/i $(cat datasource.txt)" global.datasource.xml
全部回答
- 1楼网友:高冷不撩人
- 2021-02-12 02:09
sed "/<\/bean>/i $(cat datasource.txt)" global.datasource.xml
再看看别人怎么说的。
- 2楼网友:樣嘚尐年
- 2021-02-12 01:12
sed "s/<\/bean>/$(cat datasource.txt)&/" global.datasource.xml
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯