I received more than 50 replies in just over 2 hours
when I was out for lunch, which force me to summerize
it right away.
Half of replies suggest to use dos2unix, I can't
believe I'm the only one don't know about this.
Other send me scripts or other way to solve this.
I don't have time to verify them, but I trust the
list:)
Thanks a lot everyone.
------------------------------------------------------
Douglas Palmer <palmer@nyed.uscourts.gov>
Please note: ^M is a control character, not a "^"
followed by a "M":
cat FILENAME | sed 's/^M//' > NEWFILE
or my dos2unix.pl Perl script: #!/usr/bin/perl while
(<>) { s/^M$//o; print $_; } exit;
Mark I." <bloch@enteract.com>
hi, are you using ftp to download them?
i think you can play with the cr setting if so.
i can't remember if it's on or off... but it'll
strip stuff from non unix files.
you can make it default by adding it to your ~/.netrc
(see man ftp).
or not, and you want to cleanse them in a bunch,
you can do at the command line:
cat foo | sed s/^M//g > foo.stripped
if you want to convert the file to the same name maybe
this will help
make a script:
(this assumes more or less well behaved file names...)
#!/bin/sh
mv "$1" "$1".prestripped
cat "$1".prestripped | sed s/^M//g > "$1"
(i add the ^M in my file in vi with cntl-v, cntl-m)
if you're feeling brave you might add rm
"$1".prestripped to
the last line. :)
hope that helps
-Mark
Yizhong Zhou <zhou@mathworks.com>
The following line should do the trick if you have
perl:
cat foo | perl -e 'while (<STDIN>) {s/\r\n/\n/;print}'
Rasana Atreya" <rasana_atreya@hotmail.com>
If you vi the file, you can do : s/^M//g where ^M is
Control-V/Control-M You could poosibly put this in a
sed script. Rasana
Jack Burton <jburton@brio.com>
How about cat originalfile | sed 's/^M$//g' >
/tmp/tmpfile mv /tmp/tmpfile originalfile You enter
the control M by typing Control V and then Control M
Duane Gran <ragnar@spinweb.net>
Matthew, I too have experienced this annoyance. If I'm
in vi, I use the following regular expression to solve
it: %s/^M//g Note that you produce ^M by pressing
ctrl-v and then pressing enter. However, this is very
helpful if you want to do this to many files, but I
would be interested if you do find a script to do
this. Duane Gran SolarisCentral.org
Michael DeSimone" <michael@desimone.net>
You can do it in vi or write a sed script and pump
them through. the regular expression is (in vi)
:%s/^M//g for the ^M you have to know the secret key
sequence :-D which is hold down the control key and
press "v" release "v" and still holding the control
key hit "m" the control v is the secret to generate
the control character if you ever need another one ^H
or what ever. You can also re ftp the files in ASCII
mode the reason the ended up with the ^M is because
the went over in binary mode. If I was to confusing
let me know I will try to explain better. Michael
DeSimone Computers & Stuff
Mark Olson <mark_olson@adc.com>
man tr; tr -d \015 < dosfile > unixfile HTH,
Mark
TED BACKHERMS" <DMVTJB@dmv.state.va.us>
Use vi editor and when coding the s/before/after/g
syntax, use ctl-v to then enter ctl-m as a literal
character in the before string, with // as the after
string. If you put a '$' after the ctl-m, it only
applies to ctl-m at end of line. If you need to do
this in batch using sed, setup the sed script the same
way using the vi editor to enter the ctl-v ctl-m
sequence. Ctl-v means: "take the next keystroke as a
literal instead of as input. This allows you to put
tabs in echo statements using ctl-v tab. Let me know
if this helps.
Todd Boss <boss@netcom.com>
you could wash every file through a quick script like
this:
#!/bin/sh
# replaces ; and end of line w/ carriage return and go
on next line
sed -e '1,$ s/;$/\ go/' $FILE > $FILE.1 this doesn't
get rid of the ^M itself, but actually the last
character of each line... i think there's also a
dos2unix utility out there. boss
Oliver Hemming <ohemming@winstar.com>
cat filename | col -b > filename.updated
Marcos Assis Silva <root@songa-monga.onda.com.br>
tr -d '\015\032' < input_file > output_file
Tim Pointing <Tim.Pointing@dciem.dnd.ca>
tr -d '\15' < file1 > file2
Jarrett Carver" <solarboyz1@hotmail.com>
#!/usr/local/bin/perl
#remove the ^M character, this is a windows/notepad CR
character
#The ^M character has is ASCII Character 13. See man
ascii.
$m = chr(13);
while (<>) { chomp; s/$m//g; print "$_\n"; }
close INPUT;
NBP <kwave@kineticwave.com>
while (<>) { $_ =~ s/\cM\n/\n/g; print $_; }
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:14:08 CDT