[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wc -l behaviour
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: Re: wc -l behaviour
- From: Josh Carroll <josh_(_dot_)_carroll_(_at_)_gmail_(_dot_)_com>
- Date: Fri, 17 Dec 2004 16:59:34 -0800
- Reply-to: josh_(_dot_)_carroll_(_at_)_psualum_(_dot_)_com
Why not just:
RULES=`sudo pfctl -s rules | wc -l | sed 's/ *//g'`
As others have stated, wc has always been that way and it's a lot
easier to work around it than change it and break legacy scripts.
On Sat, 18 Dec 2004 00:38:09 +0100, -f <f_(_at_)_obiit_(_dot_)_org> wrote:
> hi there,
> i am cooking a script and i need the number of rules present in pf.
> my problem is with wc. i feel that it doesn't seem to follow the unix
> philosophy truly. i would except that when telling wc to return
> the number of lines of an output, it would do just that. but in
> reality it returns whitespace AND the number:
> kripel> sudo pfctl -s rules | wc -l
> kripel> RULES=`sudo pfctl -s rules | wc -l`
> kripel> echo $RULES
> kripel> echo "$RULES"
> kripel> echo "'$RULES'"
> ' 0 '
> the last three commands are confusing for me. why is there
> no whitespace w/o the quoting?
> why the extra whitespace? could the behaviour be changed
> that when one of -c, -l, -m, -w was specified, the whitespace
> was trimmed? isn't that sensible?
> to my embarrassment, i was born in bed with a lady!
Visit your host, monkey.org