How to make portable, readable and accessible in a distinctive way from the command line?

The standard comparison tool is very useful for finding lines in a file that is different, but it does not work very well for differences for each character. I often have to combine texts by nature (i.e., written text, not code), changed without synchronization on different computers (yes, I know that I shouldn't, but anyway). Besides adding a paragraph or two, I could change the comma, spelling error, or other small change in the text that was previously common to both files.

Diff will tell me which lines are changed, but since there may be several differences in each line, I must carefully scan the lines to find each physically small but important diff per line. After fixing, I have to repeat the difference to make sure that I did not miss any changes. This gets even worse when the lines are formatted in a paragraph (i.e., One line in a paragraph), and when many consecutive lines have such small differences.

At the moment, I have to admit that I usually upload both files to Microsoft Word and use the built-in diff function. Of course, it is inconvenient to run a huge package, such as Word, to find small differences, but at least it compares files on a "by nature" basis.

I really want to use Unix. A small and cute tool or script that performs character matching over text, i.e. Not based on a line, able to ignore line endings, reporting some kind of reasonable ascii-art and completely suitable for use in scripts from the line command?

There is another question for this: Using 'diff' (or something else) to get character level differences between text files , but this question was satisfied by lib, an example of which is a web tool, I would prefer something in the command line.

+7
command-line comparison unix diff character
source share
2 answers

I'm not sure if this will fit your "command line" criteria, but I use gvim / vim daily for this purpose.

  • Open the files you want to split, for example:

     gvim -d file1 file2 
  • Make the window full screen to make it easier to see

  • Make the split windows inside gvim equal in size with the command: Cw = (this is Control + W and then = )

  • To better see lines formatted in a paragraph, type :set wrap , then switch to another split window with Cw w (or with a mouse click), and type :set wrap there too

  • To move between the changes, use [c and ]c . To merge the changes, use dp ("diff put") and do ("diff get / get").

Lines with differences are highlighted, and differences in the line are also highlighted in a different color. Hope this does what you need. gvim can do even more for you, for example merging one file with another. You can find out more with the command :help diff (inside gvim ).

You can also try kdiff3 , it might be easier than learning vim .

+4
source share

It seems that the closest we can get is vimdiff janos answer, although this is not a command line.

A close alternative, which is well supported, is included in major distributions (e.g. Debian and even Cygwin), command line and logging, and the ability to ignore wdiff line wdiff . wdiff can be used in the same way as standard diff. Unfortunately, it is not based on symbols, it is based on words.

For human use, wdiff is probably close enough; Finding a single inconsistency symbol within a word is quick and easy. The main disadvantage is that it cannot be used in programs and scripts if the goal is to search for single characters.

In fact, there is no supported command line character diff: - (.

0
source share

All Articles