
执行后,在a文件的第n行插入echo "haha"
用第二种方法也可以。一般实现:
执行后,在a文件的末尾行插入haha
1、放在</bean>后面比较简单sed -i '/\<\/bean\>/r datasource.txt' global.datasource.xml
2、放在</bean>前面的话,得先计算出</bean>行数,然后计算出前一行
#!/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
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)