Link to home
Start Free TrialLog in
Avatar of sda100
sda100Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Producing differences between 2 text files

I would like to see the changes (only additions) that have been made since I last took a backup of a text file (eg.  /var/log/messages)

I tried "diff oldfile newfile", but that produces the wrong kind of output.  So I thought about doing a "wc -l" on the old file, then printing all the line from the result of wc -l, to the end of the file using sed.  This would probably work, but something inside me is nagging saying there's a better way of doing this.

Any ideas?

Thanks,
Steve :)
ASKER CERTIFIED SOLUTION
Avatar of Heem14
Heem14

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Duncan Roe
What kind of difference output do you want if diff gives you "the wrong kind of output"? diff delineates what's inserted (or appened) c/w what's changed. Tell us what you *do* want and we'll see what we can do.
Avatar of sda100

ASKER

Thanks for the replies.  The output I want is exactly what Heem14s answer gives.  ie. the extra lines between an archived copy of a log file, and the current copy.  In that example, you only need -3, and providing you have the larger file first, then the output is perfect.

I'll leave this open for a day or two longer in case there are more replies.

Steve :)