在文件某一行(这里是最后一行)加上abc
sed '$ w temp1' file1
sed '$a\abc' temp1>temp2
tr "\n" " "<temp2>temp3
newlastline=`cat temp3`
sed '$ d' test
sed '$a\'"$newlastline" file1
=======================
sed -i '$ s/$/abc/' file1 #更简单的方法
sed '$ w temp1' file1
sed '$a\abc' temp1>temp2
tr "\n" " "<temp2>temp3
newlastline=`cat temp3`
sed '$ d' test
sed '$a\'"$newlastline" file1
=======================
sed -i '$ s/$/abc/' file1 #更简单的方法
No comments:
Post a Comment