sed 's/^/HEAD&/g' test.file 每行开头增加HEAD sed 's/$/&TAIL/g' test.file 每行结尾添加TAIL sed '/./{s/^/HEAD&/;s/$/&TAIL/}' test.file