tr -d \r <inputfile >outputfile
Or, you could use awk:
awk '{sub(/\r$/,"");print}'
The awk command assumes that each line ends in the DOS-style, though. =P
On 2/26/06, Anna <[EMAIL PROTECTED]> wrote:
On Sat, Feb 25, 2006 at 01:40:40PM -0500, [EMAIL PROTECTED] wrote:
>
> Hi Folks,
>
> I finally got MEPIS Linux to access my VFAT 32 partitions. I was able to update some simple text files but ran into two problems:
>
> (1) End-of-lines were replaced by unprintable characters. I think 0d0ah was being replaced by 0ah.
>
> (2) I would end up with two versions of the file; one FILENAME.EXT the way I wanted it; the other as FILENAME.EXT~ without any changes applied. (I only want the first one.)
>
> I was using Kedit.
>
> Any thoughts on how to fix these?
Hi Jennifer,
Many distributions come with a utility named unix2dos (or maybe
unixtodos) that will convert the line endings in a file from unix type
to dos (windows) type. I don't have it on my system, so I can't tell
you how to use it... but that's what man pages are for. ;)
Another way to "fix" a file is with vi. open a file with vi, set the
file format to 'dos' and then write and quit. do that like this...
$ vim whateverfile.txt
# once vim starts type (without the quotes) ":set ff=dos"
# and press enter
# then type ":wq" and press enter
typing ":" tells vi you're going to enter a command. follow that with
the command and press enter. the "wq" command tells vi to write the
file and quit. when you write the file with the 'ff' parameter set to
"dos", the line endings written with be what you're looking for: 0d0ah
There are other ways of course. Because vi is text based, you can
script the above if you want, which is cool. Or you can write a little
perl/python/whatever program. :) for instance, this one seems to work
for me:
# on a command line...
$ perl -wpi -e 'chomp; s/$/\r\n/;' whateverfile.txt
If you use that, make sure whateverfile.txt is definitely formatted with
unix style line termination, because if it's already dos then this will
add an additional useless/confusing '\r' character to the end of each
line, and your situation will be worse.
have fun. :)
- Anna
_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug
--
If UNIX doesn't have the solution you have the wrong problem.
UNIX is simple, but it takes a genius to understand it's simplicity.
_______________________________________________ RLUG mailing list [email protected] http://lists.rlug.org/mailman/listinfo/rlug
