[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wc feature request
From: |
Michael V. Antosha |
Subject: |
Re: wc feature request |
Date: |
Wed, 7 Oct 2020 14:45:04 +0300 |
hello Alex,
The following should do the trick without extending wc functionality:
SOME_COMMANDS | test "$(wc -l)" = YOUR_NUMBER
Proof of concept:
### { for n in {1..17}; do echo "$n"; done | test "$(wc -l)" = 17;
} && echo ZERO || echo NONZERO
ZERO
### { for n in {1..17}; do echo "$n"; done | test "$(wc -l)" = 18;
} && echo ZERO || echo NONZERO
NONZERO
Have a nice day!
Michael.
On 10/7/20, A B <alexanderashleyboese@gmail.com> wrote:
> I mean if you want to get picky about it and have this work exactly like
> grep -q, then you need to make the flag accept a threshold value, which it
> should match or exceed.
> So maybe: wc -l -q3
>
> That doesn’t have the same intuitive feel to me, but it wouldn’t violate the
> notion of how exit codes should be used either.
>
> -Alex Boese
--
Michael V. Antosha