Using vimdiff to find differences in a specific column

I have a very large csv file where each field has the same width (hence, each line has the same width). I need to find the differences in a specific column.

When I open 2 files in vimdiff, most lines are marked as diff, because there is a regular change in the datetime field (say, columns 10-15). This field is correctly colored red for a difference. But I'm interested in, say, columns 50-60, in which there will be only a few differences in the entire file.

My only solution so far is to delete parts of the file that I don't need :%s/^.\{49} , but this is very concise because the files are so big.

Is there a better solution without having to modify files?

+4
source share
1 answer

Would comparing specific fields be appropriate?

 vimdiff <(awk -F',' '{print $3}' a.csv) <(awk -F',' '{print $3}' b.csv) 

Or, if you need a comparison between multiple fields:

 vimdiff <(awk -F',' '{print $2","$3}' a.csv) <(awk -F',' '{print $2","$3}' b.csv) 
+5
source

Source: https://habr.com/ru/post/1488234/


All Articles