grep 'gateway' infile > outfile #### perl -ne'print if /gateway/' infile > outfile #### perl -ne"print if /gateway/" infile > outfile #### # Usage: script.pl infile outfile # or # Usage: perl script.pl infile outfile use strict; use warnings; my ($qfn_in, $qfn_out) = @ARGV; open(my $fh_in, '<', $qfn_in) or die("Unable to read file \"$qfn_in\": $!\n"); open(my $fh_out, '>', $qfn_out) or die("Unable to create file \"$qfn_out\": $!\n"); while (<$fh_in>) { if (/gateway/) { print $fh_out $_; } }