用sed在一个文件的每一行开头或者结尾添加内容

例如,a.txt文件的内容如下:

test1

test2

用sed -i s/$/hello/g a.txt可以在a.txt结尾添加hello字符串。a.txt结果如下:

test1hello

test2hello

用sed -i s/^/hello/g a.txt可以在a.txt开头添加hello字符串。a.txt结果如下:

hellotest1

hellotest2

猜你喜欢

转载自zzuwxf.iteye.com/blog/1404863