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

wc -l behaviour



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!