> Short explanation, what I intent to do: > I have two directory trees. One is on my hd, the other one on a > DVD-RAM, both containing lots of files. The directory structure > is very similiar. > > To proof, that the DVD-RAM has no file, which does not exist on the > hd I generate a checksum, (whirlpooldeep) of each file on the DVD-RAM > and on the hd. To make the output useable as input for "uniq" I > decided to insert either "dvdram" or "hd" after the checksum. Then I > put both files into one and sort the whole thing - key are the > characters of the checksum only. > > Then (and this the part of vim): If I find to rows which have the > word "DVD-RAM" in their second column I found one file on the > DVD-RAM, which is not on the hd.
Hmm...this sounds like something I'd do outside of vim, though I'll try my hand at a vim solution too. On a *nix system, I'd use your original source files (hd.txt and dvd.txt) and the "join" tool. bash> join -a 1 <(sort hd.txt) <(sort dvd.txt) > output.txt If you don't have bash (or the ability to make dynamic FIFOs like the above syntax), you can rewrite that as sh> sort hd.txt > hd_sorted.txt sh> sort dvd.txt > dvd_sorted.txt sh> join -a 1 hd_sorted.txt dvd_sorted.txt > output.txt sh> rm hd_sorted.txt dvd_sorted.txt The output of this will be one row for each item in hd.txt in sorted order. If there was a matching checksum in dvd_sorted.txt, it would be appended to the line. You'd then likely be interested in lines that don't have "dvdram" in them (or only have three fields rather than five fields). Or, you can swap the "-a 1" for "-a 2" to get everything that's in dvd.txt with extra info from hd.txt. I've done something like this in pure vim by doing something like :e dvd.txt :%s/^\(\S*\)\(.*\)/:%s#\1.*#\& \2!e :%y :sp hd.txt @" It basically converts your dvd.txt into a vim-script that can be run across hd.txt to append the remainder ("dvdram /path/to/file") to each line in hd.txt. It then yanks the file into the scratch register and then executes that register. In theory, you could change those last three bits to :w temp.vim :sp hd.txt :so temp.vim It's a pretty horrible hack, but I tend to use it fairly regularly. Swap hd.txt and dvd.txt if you want the other order. The script basically turns vim into a glorified SQL "LEFT OUTER JOIN" statement. If you're just interested in checksums that are in hd.txt that aren't in dvd.txt, you can use something similar: :e dvd.txt :%s/^\(\S*\).*/:sil! g#\1#d :w temp.vim :sp hd.txt :so temp.vim which will nuke all the lines in hd.txt that have checksums in dvd.txt so that the only thing remaining is files that aren't in in dvd.txt While none of the above does what you originally describe (vertical searching) but seems to provide the information you're looking for. Just a few ideas. -tim