Or if you're on a windows machine without grep perl -ne'print if /TWO/' b2bclient-gateway-heartbeat.log > output.txt
If it is part of a larger task then
my $in_file = 'b2bclient-gateway-heartbeat.log'; open my $in_fh, '<', $in_file or die "Could not open file $in_file: $! +"; my $out_file = 'output.txt'; open my $out_fh, '>', $out_file or die "Could not open file $out_file: + $!"; while ( my $line = <$in_fh> ) { print {$out_fh} $line if $line =~ /TWO/; } close $in_fh or die "Could not close file $in_file: $!"; close $out_fh or die "Could not close file $out_file: $!";
In reply to Re: How to read a text file, extract a records that contains a string, export the result into a temporary file
by hipowls
in thread How to read a text file, extract a records that contains a string, export the result into a temporary file
by tuakilan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |