perl -epi.bak "print if(m/foo/);" foo.txt bar.txt baz.txt