----- Original Message ----- From: "Zak B. Elep" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, March 27, 2007 12:05 PM
Subject: Re: [plug] My favorite text editors: JOE and GEDIT


Rafael Sevilla <[EMAIL PROTECTED]> writes:

Why use vi when he could far more easily do the same with sed? Would
be a lot faster too, especially if the files are in any way large:

sed -e 's/\r$//' doslineending-file >unixlineending-file

Change dos.*file and unix.* file to $1 and $2, prepend a #!/bin/sh on
that, and save it as bin/dos2unix, and there you go.

To go the other way:

sed -e 's/$/\r/' unixlineending-file >doslineending-file

Same, this is bin/unix2dos.

although there are thousand ways to skin a cat... same true goes with the problem above...

another simple solution is to use "tr" - translate characters...

in dos.. an end of line indicates two characters ... carriage return character(13) plus a newline character(10) in that order... while in unix.. an end of line indicates a newline character (10) only... to convert it to unix file.. all you need is to delete or remove the carriage return character...

tr -d "\r" < dosfile.txt > unixfile.txt

fooler.




_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph

Reply via email to