[BusyBox] Problem with grep

Gyorgy Farkas gf.mail at freemail.hu
Tue Jun 7 16:37:29 UTC 2005


Andreas 'ads' Scherbaum <adsmail at wars-nicht.de> wrote:

> i got some trouble using the busybox grep:
> 
> HA-Switch /etc/root # grep src /proc/net/ip_conntrack | wc -l
>       5
> HA-Switch /etc/root # cat /proc/net/ip_conntrack | wc -l
>       9
> 
> Every line in /proc/net/ip_conntrack contains a string
with "src" in it,
> but the grep does only find half of them.
> 
> As a workaround i could use "cat /proc/net/ip_conntrack |
grep ...".
> This works always and returns all expected lines.


Yes, you could always get correct result from a "frozen" file
for example

cat /proc/net/ip_contrack | grep src | wc -l
cat /proc/net/ip_contrack | grep -c src

cp /proc/net/ip_contrack /tmp/ip_conntrack
grep src /tmp/ip_conntrack | wc -l
grep -c src /tmp/ip_conntrack

IMHO not a too good idea to read - probably partially - a
fairly "live" file into the - probably circular - buffer of
grep, and working on it.


Cheers,
George.




More information about the busybox mailing list