[Top][All Lists]

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

Re: Diff utilitiy not working

From: Bob Proulx
Subject: Re: Diff utilitiy not working
Date: Sat, 30 Jul 2011 12:34:55 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

varunesh wrote:
> Example:
> f1.txt
> sam
> varun
> ramesh
> babu
> f2.txt
> babu
> sam
> I need the output of 
> varun
> ramesh

It will probably be necessary to sort those two files.  The diff
program displays differences that are needed to turn the first file
into the second file and that includes the file ordering.

I would sort the files and then use the 'comm' program.

  $ sort -o f1.txt f1.txt
  $ sort -o f2.txt f2.txt
  $ comm -23 f1.txt f2.txt

> < babu
> \ No newline at end of file
> ---
> > babu
> > sam
> \ No newline at end of file

That message saying "No newline at end of file" is an indication of a
problem.  A line of text is terminated by a newline.  Here is an
illustration of the difference.  The first shows the bytes with a
newline and the second one is missing the newline.

  $ printf "abc\n" | od -c -tx1
  0000000   a   b   c  \n
           61  62  63  0a

  $ printf "abc" | od -c -tx1
  0000000   a   b   c
           61  62  63

If there isn't a newline on the end then the results may be undefined
or implementation defined.  However you are creating those files you
should make sure that each line is a valid text line or you will have
problems somewhere.


reply via email to

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