in reply to Re: Need help copying "logs" to another file.
in thread Need help copying "logs" to another file.

Note that the code above is doing roughly the same as:

$ ls /path/*.log | grep -v filename_exclude_pat | xargs grep -h line_include_pat >output.txt

right, but note also that the above is doing roughly the same as (a bit expensive as it process every line of unneeded files even if skip them):

perl -lne 'next if $ARGV=~/filename_exclude_pat/;print if $_=~/line +_include_pat/' *.log > output.txt

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^3: Need help copying "logs" to another file. -- oneliner
by haukex (Archbishop) on Mar 29, 2017 at 13:17 UTC

    Good point :-) Less expensive:

    perl -ne 'INIT{@ARGV=grep{!/filename_exclude_pat/}@ARGV} /line_include +_pat/&&print' /path/*.log >output.txt