I have two files, a and b. Each has the same number of records (over 10,00,000 actually), and each line in either file complements the data on the same line in the other file. I want to do some pattern matching on one of the files (say a), and output the matching lines to a third file, while at the same time writing the corresponding lines in file b to a fourth file. So both output files should have the same number of records with the data relationship for each line in both files maintained.
I imagine some trivial way exists to do this, but I haven't thought of it yet.