logo       

Re: New tool for textutils: msg#00112

gnu.core-utils.bugs

Subject: Re: New tool for textutils

Antonio Diaz <ant_diaz@xxxxxxxxxxx> wrote:
> Recently i needed a tool for removing from a text file the lines

Thank you!
However, I'm not sure it's worthwhile to write such a program in C
when it can be done so concisely e.g., with Perl (for N=100):

> -M, --max-length=<n> remove lines longer than <n>

perl -ne 'my $x = $_; chomp; length > 100 or print $x'
perl -ne 'my $x = $_; chomp; print $x if length <= 100'

> -m, --min-length=<n> remove lines shorter than <n>

perl -ne 'my $x = $_; chomp; length < 100 or print $x'
perl -ne 'my $x = $_; chomp; print $x if length >= 100'

I readily admit that we can't expect everyone to use Perl, but for
simple things like this, adding a few examples to the manual might be
appropriate. However, there must already be good collections of useful
Perl one-liners, so maybe a pointer to such a collection would be better.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise