Thursday, 11 December 2008

SHELL: sed and tr

在文件某一行(这里是最后一行)加上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 #更简单的方法

No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter