I copied some files from a dos format to my linux machine. Now i have ^M at the end of the lines, and there are too many files for me to fix it manually. I also tried to use mtools and i still had a problem. Is there another way to convert dos text files to unix ?
Joao Coelho
---------------------------------
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
--0-1884588808-1018882832=:29128
Content-Type: text/html; charset=us-ascii
I copied some files from a dos format to my linux machine. Now i have ^M at the end of the lines, and there are too many files for me to fix it manually. I also tried to use mtools and i still had a problem. Is there another way to convert dos text files to unix ?<BR><BR>Joao Coelho<p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="$rd_url/welcome/?http://taxes.yahoo.com/">Yahoo! Tax Center</a> - online filing with TurboTax
--0-1884588808-1018882832=:29128--
_______________________________________________
Redhat-install-list mailing list
Redhat-in...@redhat.com
https://listman.redhat.com/mailman/listinfo/redhat-install-list
:%s/[ctrl-v][ctrl-m]//g
where the [] indicate key-presses, not actual typing. The line would read,
before you press enter:
:%s/^M//g
if you type it correctly. you type :%s/ and then type CTRL-V and then
CTRL-M (or just press enter), then type //g and it should look just like
the second example again. When you press enter, all instances of ^M will be
replaced with nothing.
--
Karl L. Pearson
Senior Consulting Systems Analyst
Senior Consulting Database Analyst
ka...@ourldsfamily.com
http://consulting.ourldsfamily.com
My Thoughts on Terrorism In America:
http://www.ourldsfamily.com/wtc.shtml
On Mon, 15 Apr 2002, Joao Coelho wrote:
I copied some files from a dos format to my linux machine. Now i have ^M at the end of the lines, and there are too many files for me to fix it manually. I also tried to use mtools and i still had a problem. Is there another way to convert dos text files to unix ?
Joao Coelho
---------------------------------
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
_______________________________________________
> From: Joao Coelho <ofi...@yahoo.com>
> Subject: converting files from dos to unix
> To: redhat-in...@redhat.com
>
> I copied some files from a dos format to my linux machine. Now i have ^M
> at the end of the lines, and there are too many files for me to fix it
> manually. I also tried to use mtools and i still had a problem. Is there
> another way to convert dos text files to unix ?
>
> Joao Coelho
>
You don't mention what OS release you're runninng. RH 7.2 has "dow2unix"
(Solaris has that too).
Emacs or vi can convert for you.
You can use "tr":
tr -d '\015' <infile >outfile
though you may want to put it into a script to simplify the renaming.
You can use perl to do the change and the rename
perl -pi -e 'tr /\r//d' FILENAME
or
perl -pi.bak -e 'tr /\r//d' FILENAME
if you want to save the original as a .bak.
--
pete peterson
Teradyne, Inc.
7 Technology Park Drive
Westford, MA 01886-0033
pete.p...@teradyne.com or pete...@genrad.com
+1-978-589-7478 (Office); +1-978-589-2088 (Closest FAX);
+1-978-589-7007 (Main Teradyne Westford FAX)
Probably the easiest way to do it is install the dos2unix rpm.
I usually use dos2unix with the -k option. From the man pages:
-k --keepdate
Keep the date stamp of output file same as input file.
On Mon, 2002-04-15 at 10:00, Joao Coelho wrote:
> I copied some files from a dos format to my linux machine. Now i have ^M at the end of the lines, and there are too many files for me to fix it manually. I also tried to use mtools and i still had a problem. Is there another way to convert dos text files to unix ?
_______________________________________________
sed 's!.$!!g' < infile > outfile.
This will substitute nothing on the last character of each line, therefore
removing the '^M'.
Good luck!
"Joao Coelho" <ofi...@yahoo.com> wrote in message
news:2002041515003...@web10304.mail.yahoo.com...
#! /usr/bin/perl -w
while ($file = shift(@ARGV)) {
$new = $file.".unix";
die "file does not exist\n" unless (-e $file);
open(FILE,">$new");
@file = `cat $file`;
for (@file) {
s/\r//;
print FILE $_;
}
}
The command line is <thisfilename dos.txt> the output will be dos.txt.unix
with all the carridge returns removed
Saul Arias <zh...@yahoo.com> wrote in message
news:1018885761.1...@saul.etires.com...