How can I convert "DOS" .txt file to Unix .txt file

13,405

Solution 1

dos2unix is a tool for converting line endings.

Solution 2

Most Unix installations include the 'tr' command ('tr' is short for 'translate') - you could use that to convert your input file with DOS text to output Unix text format:

tr -d '\r' < dos.txt > unix.txt

HTH!

Solution 3

On Debian-derived (Ubuntu, etc) systems, you want the tofrodos package, which provides the commands todos and fromdos. (fromdos is the one you are looking for.)

On RedHat-derived systems (RHEL, Centos, Fedora, etc), you want the dos2unix package, which provides the commands dos2unix and mac2unix. To convert in the other direction, you'll want the unix2dos package, which provides the unix2dos command.

Share:
13,405

Related videos on Youtube

Rn2dy
Author by

Rn2dy

Ninja is too unreliable;

Updated on September 18, 2022

Comments

  • Rn2dy
    Rn2dy almost 2 years

    Possible Duplicate:
    Convert CRLF's to line feeds on Linux

    How can I convert a DOS text file to Unix text file, so I can use my Linux parser properly?

  • susie
    susie about 13 years
    My Ubuntu does not have it, how to get it?