What not to do with grep

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
grep -r somepattern * > grepresults.txt

I couldn't figure out why my computer was bogging down so badly. By the time I did figure it out I had a 22 gig text file :confused:
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Along those lines ... I discovered today that MySQL does not like receiving a 3MB query via the C API. Couldn't figure out why the connection always dropped, until I actually looked at the size of the insert query that it was trying to push through :p
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I did it at the root of my dev directory (this is windows, dev means development, not device). Not that it matters where you do it, if the pattern matches anything you're screwed.
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: kamper
I did it at the root of my dev directory (this is windows, dev means development, not device). Not that it matters where you do it, if the pattern matches anything you're screwed.

Actually, only if it matches something before it scans the file you're directing the output into.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: n0cmonkey
I'm guessing you did that in /? I do stuff like that all the time, just not in /.
If I had done it in / would it eventually hit /dev/random or something like that and just spin forever? That would probably be hard on processor time but not on the disk. In my example there was almost no activity at all going on (according to the Task Manager) which is why I was so confused as to what was happening :p
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: kamper
Originally posted by: n0cmonkey
I'm guessing you did that in /? I do stuff like that all the time, just not in /.
If I had done it in / would it eventually hit /dev/random or something like that and just spin forever? That would probably be hard on processor time but not on the disk. In my example there was almost no activity at all going on (according to the Task Manager) which is why I was so confused as to what was happening :p

Not sure. I guess I can try it when I get home. I've never tried it in / or /dev. I typically only do things like that in /etc or ~/. :p
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Originally posted by: BingBongWongFooey
Yeah it would get stuck on /dev/{{u,}random,zero} (probably others for various reasons too)

Never thought of that, hehe, ran out of memory after a second or two when greping for blah in /dev/zero

Hey look, I have 400 MB of free RAM! :D

Wonder if I can sell a script that does that as a "Memory optimizer" ;)