FreeOZ论坛
标题:
add \ to the end of each line
[打印本页]
作者:
valpa
时间:
30-12-2010 14:08
标题:
add \ to the end of each line
sed "s/\(.*\)/\1 \\\/g" will do the work.
Why need \\\ here. ( three \ char)
作者:
coredump
时间:
30-12-2010 14:27
I don't think it work, might be:
s/\(.*\)/\1\ \\/g
this first '\' after '\1' is useful for the space, the rest '\\' ouput '\'
作者:
李大锤
时间:
30-12-2010 15:53
有点绕口吧,可以再简练一些
[root@redhat5 Arrays]# cat 1.txt
1 2 3
1 2 3
1 2 3
[root@redhat5 Arrays]# sed 's/$/\\/g' 1.txt
1 2 3\
1 2 3\
1 2 3\
作者:
coredump
时间:
30-12-2010 15:58
标题:
回复 #3 李大锤 的帖子
对,你这样写就可以了,最简单,楼主应该是不知道$用作行尾,^用作行首
作者:
valpa
时间:
7-1-2011 20:57
标题:
回复 #3 李大锤 的帖子
明天再给你分,多谢,我一直试啊试啊,就是试不出来
楼下的core,我知道^$, 是最基本的东西
作者:
ubuntuhk
时间:
8-1-2011 12:23
我不会用sed,一般用awk来实现:
cat 1.txt | gawk '{print $0"\\"}'
复制代码
作者:
cfk
时间:
9-1-2011 16:48
\\\
第一个是告诉bash第二个\转义,第二个告诉regex engine第三个\转义
欢迎光临 FreeOZ论坛 (https://www.freeoz.org/ibbs/)
Powered by Discuz! X3.2