Posted By

fontanon on 11/01/08


Tagged

unix text dos convert


Versions (?)

Convert dos text file to unix text file


 / Published in: Bash
 

Maybe you know that dos2unix command (included in tofrodos package) makes the conversion between dos and unix text files. But, what if you don't want to install tofrodos package or dos2unix fails? That's the bash solution i found over the web.

  1. cp mydosfile.txt mydosfile.txt.bak
  2. tr -d "\r" < mydosfile.txt.bak > mydosfile.txt

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jaduks on December 21, 2008

installing tofrodos can be avoided by making use of a command called flip

Usage:

flip - do newline conversions between **IX and MS-DOS

-u Convert to **IX format (CR LF => LF, lone CR or LF unchanged, trailing control Z removed, embedded control Z unchanged).

-m Convert to MS-DOS format (lone LF => CR LF, lone CR unchanged).

A post about flip can be found here: http://unstableme.blogspot.com/2008/04/linux-flip-command-alternative-of.html

Posted By: wnasich on August 19, 2010

You could use vim to get the same result, just do

:set fileformat=unix

You need to login to post a comment.