Redian新闻
>
how to get rid of the ^M in files?
avatar
how to get rid of the ^M in files?# Unix - 噫吁兮,危乎高哉
r*u
1
Is the ^M in unix files the "enter" in windows files? Any easy way to
get them out? Many thanks.
avatar
r*u
2
I got it.
in VI use the command :%s/^V^M//g
in unixshell sed 's/^V^M//g'foo > foo.new
where ^V^M means control+v then control+M.

【在 r*u 的大作中提到】
: Is the ^M in unix files the "enter" in windows files? Any easy way to
: get them out? Many thanks.

avatar
l*g
3
u don't need the /g part, 'coz there will be only one ^M per line, otherwise
you got a problem.

【在 r*u 的大作中提到】
: I got it.
: in VI use the command :%s/^V^M//g
: in unixshell sed 's/^V^M//g'foo > foo.new
: where ^V^M means control+v then control+M.

avatar
r*u
4
I'm not sure what this g means here. But it seems ok. Could you tell me
what the problem would be? thanks.

【在 l****g 的大作中提到】
: u don't need the /g part, 'coz there will be only one ^M per line, otherwise
: you got a problem.

avatar
c*v
5
dos2unix

【在 r*u 的大作中提到】
: I'm not sure what this g means here. But it seems ok. Could you tell me
: what the problem would be? thanks.

avatar
G*T
6
dos2unix, unix2dos

【在 l****g 的大作中提到】
: u don't need the /g part, 'coz there will be only one ^M per line, otherwise
: you got a problem.

avatar
r*m
7
dos2unix: Command not found.
how can I do?

【在 G**T 的大作中提到】
: dos2unix, unix2dos
avatar
d*n
8
vi, :%s/^v^m//g

【在 r**m 的大作中提到】
: dos2unix: Command not found.
: how can I do?

avatar
l*t
9
dos2unix.pl xxx.dos > xxx.unix
The following is the perl file. Don't forget to make it executable.
#!/usr/bin/perl
while(<>){
if($_ =~ /(.*)\r/)
{
print($1, "\n");
}
else
{
print($_);
}
}

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