For example, I have a text file, each line is a long string. I want to exclude 2 "segments" of this string, say columns 1-7 and 20-22. So the bottom 2 lines below would be a match:

123456789012345678901234567890 
------------------------------
xxxxxxxAAAAAAAAAAAAxxxBBBBBBBB
yyyyyyyAAAAAAAAAAAAyyyBBBBBBBB

I know WinMerge has an "IgnoreColumns" plugin but I have never go this working. In this example I would rename it IgnoreColumns_1-7,20-22.dll, select it in the plugins menu, and choose "Pre-Differ." but it has never worked.

I am going to be comparing huge files that I don't want to modify. I'm not opposed to stream editing them in the comparison with sed or something like that, but I would prefer not to modify the actual files. I have not chose to feed sed to diff yet just because I was hoping for for a more visual view of the data.

link|improve this question
Do you have the program open or closed when you're renaming the file? Maybe you need to restart WM or reload plugins. I just tried WinMerge (ver 2.13.20): put each line of your sample into a different file, and diffed them. WinMerge showed the difference at first, but once I loaded the plugin it said that they were identical. – afrazier Jul 29 '11 at 19:45
feedback

3 Answers

The following works on Linux and on Cygwin.

vimdiff <(cut -c8-19,23- file1) <(cut -c8-19,23- file2)

For some reason on Cygwin, Vim prompts that each file has changed since editing started and asks, "[O]K, (L)oad File:". Just type O each time.

Granted you don't get to see the omitted columns, but it is a visual, side-by-side comparison.

link|improve this answer
feedback

Just as Diogo_Rocha's answer, you could modify the file beforehand to remove the columns you do not want to test, then run diff. But with just commandline stuff.

So for your example, removing 'columns' 1-7 and 20-22 you could.

sed 's/.\{7\}\(.\{12\}\).\{3\}\(.*\)/\1\2/' test.txt > test2.txt
diff -u test2.txt whatnot.txt

Edit: Blatant thieverizing of garyjohn's better answer.

diff -u <(cut -c8-19,23- test1.txt) <(cut -c8-19,23- test2.txt) | less
link|improve this answer
question updated. i have a lot of files so copying would be a pain, but might be the best bet. but I guess my original question stands - is there a diff utility that does this out of the box? – user39160 Jul 29 '11 at 19:18
Essentially garyjohn's answer is what you need. No need to duplicate files, feed modified files on stdin to diff or his version with vimdiff. And easier with cut rather than sed. – Nicholi Jul 29 '11 at 20:01
feedback

If I could understand your doubt, you are trying to exclude or select specific colums from a text file. If it is true, you can do it with the textpad application. Install it and open your text file, then press your "Alt" key on the same time that you select specific colums from your text. With these colums selected you can copy, cut or delete each one you need.

link|improve this answer
question updated – user39160 Jul 29 '11 at 19:16
feedback

Your Answer

 
or
required, but never shown

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