c******t 发帖数: 31 | 1 用emacs打开别的text editor编辑的文件,每行末尾都有一个"^M"。
能去掉吗?看着真别扭。
谢谢。 |
p**h 发帖数: 99 | 2 you can try 'dos2unix'.
【在 c******t 的大作中提到】 : 用emacs打开别的text editor编辑的文件,每行末尾都有一个"^M"。 : 能去掉吗?看着真别扭。 : 谢谢。
|
c******t 发帖数: 31 | 3 what is this?
Is it included in emacs?
Thank you.
【在 p**h 的大作中提到】 : you can try 'dos2unix'.
|
M****d 发帖数: 26 | 4 It is a command in unix, because unix and dos treat "enter" differently.
【在 c******t 的大作中提到】 : what is this? : Is it included in emacs? : Thank you.
|
r***r 发帖数: 25 | 5
or if ur unix doesn't hv it (i think all solaris hv this command)
u can use a simple perl script.
#!/usr/local/bin/perl
require "flush.pl";
$TMP_FILE = "/tmp/dos2unix.tmp";
foreach $f (@ARGV) {
if ( -f $f) {
print "Processing $f ..."; &flush( STDOUT);
open( OUT, "> $TMP_FILE") || die "Cannot open tmp file for writing\n";
open( IN, "< $f") || die "Cannot open tmp file for reading\n";
while( $line = ) {
$l = length( $line);
if ( ( $l
【在 p**h 的大作中提到】 : you can try 'dos2unix'.
|
c******t 发帖数: 31 | 6 Thank you very much!
【在 r***r 的大作中提到】 : : or if ur unix doesn't hv it (i think all solaris hv this command) : u can use a simple perl script. : #!/usr/local/bin/perl : require "flush.pl"; : $TMP_FILE = "/tmp/dos2unix.tmp"; : foreach $f (@ARGV) { : if ( -f $f) { : print "Processing $f ..."; &flush( STDOUT); : open( OUT, "> $TMP_FILE") || die "Cannot open tmp file for writing\n";
|
h******a 发帖数: 198 | 7 onliner.
perl -pi -e 's/\cM//g' *
【在 r***r 的大作中提到】 : : or if ur unix doesn't hv it (i think all solaris hv this command) : u can use a simple perl script. : #!/usr/local/bin/perl : require "flush.pl"; : $TMP_FILE = "/tmp/dos2unix.tmp"; : foreach $f (@ARGV) { : if ( -f $f) { : print "Processing $f ..."; &flush( STDOUT); : open( OUT, "> $TMP_FILE") || die "Cannot open tmp file for writing\n";
|
a****f 发帖数: 29 | 8 solaris: dos2unix
linux: fromdos, todos
Also,
$ cat file | tr -d '\r' > newfile
【在 c******t 的大作中提到】 : what is this? : Is it included in emacs? : Thank you.
|