OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
wc -l behaviour

From: -f (fobiit.org)
Date: Fri Dec 17 2004 - 17:38:09 CST


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!