C:\>type data.txt foo bar foo bar foo foo C:\>perl -n -e "m/foo/ or print" data.txt > out.txt C:\>type out.txt bar bar C:\>