dos2unix

David de Groot david at viking.org.au
Tue Dec 20 23:12:24 CST 2005


On 21/12/2005, at 7:55 AM, Brian Astill wrote:

> I _think_ dos2unix converted DOS text EOL to Unix EOL.
> That utility is absent from Ubuntu's repositories, and Abiword,  
> OOO1 and OOO2
> cannot find DOS EOL (\n doesn't work, nor does ^p).
>
> Short of finding and using MS Word does anyone have a solution  
> which will
> remove unwanted EOL from text files?

http://kb.iu.edu/data/acux.html

 From that page, using my favourite unix util  - awk

awk

To use awk to convert a Windows/DOS file to Unix, at the Unix prompt,  
enter:

   awk '{ sub("\r$", ""); print }' winfile.txt > unixfile.txt
To convert a Unix file to Windows/DOS using awk, at the command line,  
enter:

   awk 'sub("$", "\r")' unixfile.txt > winfile.txt
On some systems, the version of awk may be old and not include the  
function sub. If so, try the same command, but with gawk or nawk  
replacing awk.



Dave


More information about the linuxsa mailing list