Redian新闻
>
what is used to represent a "tab" character in "sed"
avatar
what is used to represent a "tab" character in "sed"# Programming - 葵花宝典
e*r
1
I tried "\t" to represent a tab, but it doesn't work. thanks
bash-2.02$ less withtab.txt
fsfsdfsd = dlkgjdl
djf = dfd
bash-2.02$ sed 's/\t/ /g' withtab.txt
fsfsdfsd = dlkgjdl
djf = dfd
avatar
O*e
2
Ctrl-I

【在 e******r 的大作中提到】
: I tried "\t" to represent a tab, but it doesn't work. thanks
: bash-2.02$ less withtab.txt
: fsfsdfsd = dlkgjdl
: djf = dfd
: bash-2.02$ sed 's/\t/ /g' withtab.txt
: fsfsdfsd = dlkgjdl
: djf = dfd

avatar
e*r
3
what is that? ctrl followed by a char "l" as in "leg"?

【在 O******e 的大作中提到】
: Ctrl-I
avatar
o*o
4
are u sure you have tab in your file?

【在 e******r 的大作中提到】
: I tried "\t" to represent a tab, but it doesn't work. thanks
: bash-2.02$ less withtab.txt
: fsfsdfsd = dlkgjdl
: djf = dfd
: bash-2.02$ sed 's/\t/ /g' withtab.txt
: fsfsdfsd = dlkgjdl
: djf = dfd

avatar
e*r
5
yes, I artificially put some tabs in file for testing this.

【在 o*o 的大作中提到】
: are u sure you have tab in your file?
avatar
o*o
6
so, it's RP problem.

【在 e******r 的大作中提到】
: yes, I artificially put some tabs in file for testing this.
avatar
e*w
7
you need to escape \ with \\ ba.

【在 e******r 的大作中提到】
: I tried "\t" to represent a tab, but it doesn't work. thanks
: bash-2.02$ less withtab.txt
: fsfsdfsd = dlkgjdl
: djf = dfd
: bash-2.02$ sed 's/\t/ /g' withtab.txt
: fsfsdfsd = dlkgjdl
: djf = dfd

avatar
O*e
8
Control-EYE.

【在 e******r 的大作中提到】
: yes, I artificially put some tabs in file for testing this.
avatar
O*e
9
$ cat -T test.dat
abc^Ixyz
$ sed -e 's/\t/TAB/' test.dat
abcTABxyz
$ sed -e 's/\\t/TAB/' test.dat
abc xyz
$ sed -e 's/ /TAB/' test.dat (Ctrl-I used in the regexpr)
abcTABxyz
$ sed -e "s/\t/TAB/" test.dat
abcTABxyz
$ sed -e "s/\\t/TAB/" test.dat
abcTABxyz
$ sed -e "s/ /TAB/" test.dat (Ctrl-I used in the regexpr)
abcTABxyz
In the above examples I can type the TAB character in the shell
either using Ctrl-V followed by TAB or Ctrl-V followed by Ctrl-I.

【在 e*****w 的大作中提到】
: you need to escape \ with \\ ba.
avatar
W*W
10
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。