#! /usr/bin/ruby # given input of the form generated by mailidx-positions, # put an mbox of the messages on stdout # # use with formail like this: # # mailidx-positions > /tmp/pos # # ... then, later when you need to find something ... # # : > /tmp/msgs # grep -i '@noserose\.' /tmp/pos | egrep -v '(\.nov|~)$' | sort | uniq | mailidx-mbox | formail -D 10000000 /tmp/msgs -s > /tmp/noserose # STDIN.each { |s| (addr, pos, f) = s.split() pos = pos.to_i fd = File.open(f) fd.seek(pos) n = pos fd.each { |s| break if n != pos && s =~ /^From\s+/ puts s n += s.length } fd.close }