Tente un


cat test.txt | perl -ne 'print if /ALTER/ .. /ADD/' > test2.txt
(sous Unix/Linux).