Let's imagine I'm teaching a class, and I want to use the exam package to write up a homework assignment. I'm aware that I could compile two different PDF documents -- one containing solutions, using \documentclass[answers]{exam}, and one without solutions, using \documentclass{exam}. (Alternatively, I could make versions with and without the \printanswers directive.)
However, if the students will typeset their own solutions using LaTeX, the ideal approach would be to create two different source versions of the LaTeX file -- one with solutions and one without. Then, I could distribute the no-solution version of the .tex file (perhaps in addition to the no-solution version of the .pdf file), and students wouldn't have to worry about manually re-typing the problem statements.
With that in mind, is there any easy-to-automate way to create a copy of a given LaTeX source file with solutions removed?