[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How convert PC text to UNIX ascii



>The way to get rid of those ^M characters is to either transfer the files
>using ascii mode in ftp, or use the dtox program or dos2unix program or
>:%s/^V^M//g in vi, or a sed script or write a program or .. half a million
>ways to do the same thing (would recode do it? :)
>

Thanks Seth, that's exactly the info I was looking for. My linux pc is not
yet networked to my pc so I'm forced to transfer small via floppy for now.
I will do a search for dtox and dos2unix.  Looks like neither are a part of
debian so I searched the net for them.

Here's one solution from http://ume.med.ucalgary.ca/usenet/Linux/0053.html:

-------------------- save as dos2unix --------------------------------- 
#!/bin/sh 
sed 's/^M//' $1 
----------------------------------------------------------------------- 
-------------------- save as unix2dos --------------------------------- 
#!/bin/sh 
sed 's/$/^M/' $1 
----------------------------------------------------------------------- 


Note that the `^M' has to be produced by pressing `Ctrl-V Ctrl-M' in vi, or 
`Ctrl-QCtrl-M' in emacs. Then you can do, e.g., `dos2unix < unixfile > 
dosfile' and `unix2dos < unixfile > dosfile'. 
       ----- end ------

Those look like perl scripts. If so it's just that I'm unfamiliar with the
SED command that is throwing me off. I'll try each as a perl script anyways
just to be sure.

Andre
p.s. Here is aother solution:
cat <filename> | sed 's/^M//' <-- I tried this one, it didn't convert the
file, it ran the file (all of the print commands printed to screen.
Afterwards I typed perl <filename> and same issue exists.  I even tried
this command and piped it with ">" to create anew file still the same error
message :( 



Reply to: