echo -e "a\nb\nc" | perl -lne 'next if /b/; print' a c echo -e "a\nb\nc" | perl -lne 'last if /b/; print' a