add \ to the end of each line
sed "s/\(.*\)/\1 \\\/g" will do the work.Why need \\\ here. ( three \ char) I don't think it work, might be:
s/\(.*\)/\1\ \\/g
this first '\' after '\1' is useful for the space, the rest '\\' ouput '\' 有点绕口吧,可以再简练一些
# cat 1.txt
1 2 3
1 2 3
1 2 3
# sed 's/$/\\/g' 1.txt
1 2 3\
1 2 3\
1 2 3\
回复 #3 李大锤 的帖子
对,你这样写就可以了,最简单,楼主应该是不知道$用作行尾,^用作行首回复 #3 李大锤 的帖子
明天再给你分,多谢,我一直试啊试啊,就是试不出来楼下的core,我知道^$, 是最基本的东西 我不会用sed,一般用awk来实现:cat 1.txt | gawk '{print $0"\\"}' \\\
第一个是告诉bash第二个\转义,第二个告诉regex engine第三个\转义
页:
[1]