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

Re: wc -l behaviour



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.

Josh


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
>        0
> kripel> RULES=`sudo pfctl -s rules | wc -l`
> kripel> echo $RULES
> 0
> kripel> echo "$RULES"
>        0
> 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