Command for converting text file (Windows CR) to text file (Linux) ? - Unix

This is a discussion on Command for converting text file (Windows CR) to text file (Linux) ? - Unix ; Assume I trasferred/uploaded a text file (which was created on a Win system) to Linux system. How can I convert the eol chars to the Linux style ? I opened (and later saved) it in vi editor. But this didn't ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Command for converting text file (Windows CR) to text file (Linux) ?

  1. Command for converting text file (Windows CR) to text file (Linux) ?

    Assume I trasferred/uploaded a text file (which was created on a Win system) to Linux system.

    How can I convert the eol chars to the Linux style ?

    I opened (and later saved) it in vi editor. But this didn't help.

    What else can I do to convert it?

    Karl

  2. Re: Command for converting text file (Windows CR) to text file (Linux) ?

    On 2007-12-11, Karl Medrell wrote:
    >


    > Assume I trasferred/uploaded a text file (which was created on a Win
    > system) to Linux system.
    > How can I convert the eol chars to the Linux style ?
    >
    > I opened (and later saved) it in vi editor. But this didn't help.
    >
    > What else can I do to convert it?


    Most systems have a dos2unix command. If you don't have that, you
    can use sed:

    sed "s/\r$//" FILE

    --
    Chris F.A. Johnson, author
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
    ===== My code in this post, if any, assumes the POSIX locale
    ===== and is released under the GNU General Public Licence

  3. Re: Command for converting text file (Windows CR) to text file (Linux) ?

    On 2007-12-11, Chris F.A. Johnson wrote:
    > On 2007-12-11, Karl Medrell wrote:
    >>

    >
    >> Assume I trasferred/uploaded a text file (which was created on a Win
    >> system) to Linux system.
    >> How can I convert the eol chars to the Linux style ?
    >>
    >> I opened (and later saved) it in vi editor. But this didn't help.
    >>
    >> What else can I do to convert it?

    >
    > Most systems have a dos2unix command. If you don't have that, you
    > can use sed:
    >
    > sed "s/\r$//" FILE


    or

    tr -d '\r' newfile


    --
    Grant Edwards grante Yow! I'm wearing PAMPERS!!
    at
    visi.com

  4. Re: Command for converting text file (Windows CR) to text file (Linux) ?

    At 11 Dec 2007 20:34:49 GMT k.medrell@hotmail.com (Karl Medrell) wrote:

    >
    > Assume I trasferred/uploaded a text file (which was created on a Win system) to Linux system.
    >
    > How can I convert the eol chars to the Linux style ?
    >
    > I opened (and later saved) it in vi editor. But this didn't help.
    >
    > What else can I do to convert it?


    tr -d '\r' UNIXFile

    man tr

    (also:

    tr '\r' '\n' UNIXFILE
    )



    >
    > Karl
    >


    --
    Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
    Deepwoods Software -- Linux Installation and Administration
    http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
    heller@deepsoft.com -- Contract Programming: C/C++, Tcl/Tk


+ Reply to Thread