I have a file, foo.txt, and a regexp I want to find in that file. Each time I find the regexp, I want to take a line from another file, bar.txt, and substitute it in for the regexp match I found in foo.txt. Basically I want to do find/replace, but each time I replace I want the next replacement text to come from the next line in bar.txt.
Is there any easy shell magic to do this?