Before you go to this effort, see if you have the applications "fromdos" and
"todos" on your Linux host. fromdos changes ^M^J to ^J, while todos changes
^J to ^M^J. (This is what you want to do, even though the ^Js don't show
when you examine the file in a Linux editor -- they are the Unix newline
characters. Look at the file using "hexdump" if you want to see what I mean.)
IF not, the perl app is approximately as follows (untested, so watch for
small errors):
#!/usr/bin/perl
open (INFILE,"/some_path/some_file") ;
open (OUTFILE,">/some_path/some_other_file") ;
while ( $nextline = <INFILE> )
{
$nextline ~= tr/\r//d ;
print OUTFILE "$nextline" ;
}
close OUTFILE ;
close INFILE ;
# EOP
Since the only line above that actually does anything is the tr command, you
should be able to write something functionally identical in sed quite easily.
At 02:17 PM 3/10/00 -0600, James Ng wrote:
>can somebody teach me how do i write a perl script to delete the
>character ^M in a file.
>for example, i have a file called index.html and i want to delete all the
>^M characters in the file. Thank you.
------------------------------------"Never tell me the odds!"---
Ray Olszewski -- Han Solo
Palo Alto, CA [EMAIL PROTECTED]
----------------------------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs