2

My diff shows some numerical differences between two log files. That means for example:

fileA: 

        Parameter            n (fill abs)
        /All_Data/Height     9830400

fileB: 

        Parameter            n (fill abs)
        /All_Data/Height     9830500

SO, if the diff command is executed between the files:

% diff fileA fileB
-> 
< /All_Data/Height     9830400
---
> /All_Data/Height     9830500

I would like to set a threshold in the diff command what is to say

  1. display the difference if the discrepancy between the number is greater than 500. So 9830400-9830500=100. No differences should be displayed.
  • 1
    What did you try? – Inian Jun 7 '17 at 8:53
  • Where did you get an idea that diff will compute the arithmetic? i.e. that too floating point? – Inian Jun 7 '17 at 8:57
  • could your files contain more than one line? Are there always be only digits? – RomanPerekhrest Jun 7 '17 at 8:59
  • So if it is impossible to compile arithmetic with diff, the solution will be indeed more difficult. @RomanPerekherst: My files contain more than one line. It actually contain table of values that will not be always exactly the same between the two files.... The difference are not only digits. It can also be alphabetical.. – birdman Jun 7 '17 at 9:00
  • 1
    You need to show your input and the expected output files, comprising the many scenarios you will be having. Your current example of 0.25 vs 0.5 is just not sufficient. – user218374 Jun 7 '17 at 9:14
4

That's essentially what spiff did, and there have been a few others of the same sort (not as well known). spiff was rather fragile (dumped core easily).

  • Related: tre, used for fuzzy matching. Also fragile, to the point of being unusable. – Satō Katsura Jun 7 '17 at 9:27
  • Looks like it still lives at github.com/dontcallmedom/spiff at least – Stéphane Chazelas Jun 7 '17 at 9:28
  • @Thomas Dickey: Thank you for your answer. However I am struggling to install spiff in SLES11. spiff uses the library lcurses and lcurses uses lua. In my case lcurses is complaining with really ugly lua source code errors. Do you know other programs similar to spiff? – birdman Jun 7 '17 at 17:36
  • You've found a different spiff. Start here – Thomas Dickey Jun 7 '17 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.