bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help needed in - diverting the output of diff command to a text file


From: Stepan Kasal
Subject: Re: Help needed in - diverting the output of diff command to a text file
Date: Mon, 15 Mar 2004 10:46:29 +0100
User-agent: Mutt/1.4.1i

Hello,

On Sat, Mar 13, 2004 at 02:29:03PM +0530, address@hidden wrote:
> I am using diff command to find the difference between two files.

> When I open the output file in WINDOWS the output looks like this:
>                 1,3c1,3< :EZEE 440           03/12/04    12:09:10    
...
> ---> :EZEE 440           03/12/04    12:09:15       

> But When I use cat diff.txt, the lines are appearing as follows:
> 1,3c1,3
> < :EZEE 440           03/12/04    12:09:10      
> < :record    name     = RPZ0 
> <            date     = '03/12/04'   time = '12:09:10' 
> ---
> > :EZEE 440           03/12/04    12:09:15    
> > :record    name     = RPZ1 
> >            date     = '03/12/04'   time = '12:09:15' 

the problem is that the diff commands generates it's output with
unix-like line endings, while it preserves the CRLF endings from your
DOS style files.
Thus the lines "1,3c1,3" and "---" end with LF while the other ones end with
CRLF.

To fix the problem, try using another editor, eg. vim (www.vim.org).

Or try to fix the line endings, perhaps this way:
        diff a b | tr -d '\r'|recode /../cl >diff.txt
or
        diff a b | sed '/\r$/!s/$/\r/' >diff.txt

HTH,
        Stepan Kasal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]