Hi Alessandro! On Do, 08 Mär 2012, Alessandro Antonello wrote:
> 2012/3/8 Christian Brabandt <cbli...@256bit.org>: > > On Thu, March 8, 2012 13:45, Alessandro Antonello wrote: > >> Hi, all. > >> > >> I have a file with the following output: > >> > >> pass1 key: 9534 1CFF A92D 76B9 B52C 79E5 1D10 85E5 > >> pass2 key: 6C66 D635 3922 1D99 6FCE 8366 7992 C3DE > >> passN key: F906 930C 2FD3 6B4B 7A2C 1AF5 C314 D62C > >> > >> There are several of that 3 lines. I could ':sort' the file to find > >> duplicated > >> lines but, what I really need to know is if there are binary data of > >> 'pass1 > >> key' equal to 'pass2 key' or 'passN key'. I have 3 files with more than > >> 8000 > >> lines each. So, visually do this is tedious and error prone. I need a > >> little > >> help, please. > > > > Put the following into ~/.vim/plugins/dupes.vim > > fu! s:Duplicates() > > let res={} > > for line in range(1,line('$')) > > let key=matchstr(getline(line), '^[^:]*: \zs.*$') > > let key = '\('.key.'\)' > > let res[key] = get(res, key) + 1 > > endfor > > call filter(res, 'v:val > 1') > > call matchadd('TODO', join(keys(res), '\|')) > > endfu > > com! Dupes :call s:Duplicates() > > > > Hi, Christian. > > I tried it and it gave me the error "E51 Too many \(". > I have a lot of duplicated values. That's why the job is so error > prone. Hm, you could try to use '\%(' instead of '\('. But you seem to be done with the task anyway, so I won't update the script here now. > I need to know > if I have a pass1 value equal to a pass2 or passN. Having several pass1 values > duplicated is not an issue. Also, I can have pass2 values duplicated and passN > values duplicated. But I cannot have a pass2 equal to a passN or pass1 > and vise-versa. Mit freundlichen Grüßen Christian -- Der Krämer, der etwas abwiegt, schafft so gut die unbekannten Größen auf die eine Seite und die bekannten auf die andere als der Algebraist. -- Georg Christoph Lichtenberg -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php