To extract only the rows that contain a specific string (Perl)

IIS and Apache access log from the other, only a particular line (eg "sales" or "campaign", etc.) you want to access a survey to extract, and also that there are many cases.
As I'm sure there are ways to edit one at a time like Excel, it becomes very huge amount.

You can use the Perl script below (one-liners) can be easily extracted.
If Perl is installed, enter the following command for example.

perl -ne "print if ( /search-string/ )" inputfile.txt > outputfile.txt

"Search-string" is a string that contains the line you want the output (Perl regular expressions can be. Perl regular expressions here ).
"Inputfile.txt" extract the original file, "outputfile.txt" results for the output file.

This alone, "inputfile.txt" from "search-string" and containing the "outputfile.txt" will be written to.

Alternatively, you can not extract the text, if the log file.
csv can also be used when you want to extract only the lines that contain specific strings from a file.

Tags: Perl

HOME > Articles 2011 > to extract only the rows that contain a specific string (Perl)

HOMEHOME CategoryCategory HistoryHistory

Site Search :

[HTML link code]