[Top][All Lists]
[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 22:20:08 +0200 |
Antonio Diaz <address@hidden> wrote:
> I agree it is perhaps not worth to have another program for such a
> task, but I think it should be not too dificult to add that
> functionality to the program "cut".
Sorry, but it would not be appropriate to add
such functionality to cut.
...
> I like much more "The software tools philosophy" than the "learn a new
> programming languaje for every task philosophy". And possibly many of
> the GNU users that aren't sysadmins agree with this.
>
> The Perl motto is "There's more than one way to do it". Well, my way
> is not to use it. :) (Of course my way can't be appropiate for
> everybody).
We don't need Perl for this. Just use grep (or sed or g/awk):
>> -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'
grep -E '^.{0,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'
grep -E '^.{100}'