bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New tool for textutils


From: Jim Meyering
Subject: Re: New tool for textutils
Date: Sun, 30 Mar 2003 20:13:54 +0200

Antonio Diaz <address@hidden> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]