Link to home
Start Free TrialLog in
Avatar of Chris Andrews
Chris AndrewsFlag for United States of America

asked on

How to refresh cache for searching using grep?

I'm getting old results when I run grep.

It seems to me I remember something along the lines of grep using a cache I think? And that it needs to be refreshed for a fresh search.

Can you tell me how to do that? I'm on a linux/centos machine.
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

"grep" itself doesn't have an own cache.
There is the usual filesystem cache in Unix/Linux, but you should never get old results after files have been modified, because the dirty cache pages are written to disk rather frequently!

Running "sync" forces writing of dirty pages to disk, so you can run

snyc

and retry.

To drop the whole filesystem cache you can run this (as root):

sync; echo 3 > /proc/sys/vm/drop_caches

This will not flush dirty objects, however.
>I'm getting old results when I run grep.
An example please ;)  grep has no cache as said above already.
Avatar of Chris Andrews

ASKER

hmm, interesting...

What I was doing was searching for any instances in my wordpress sites for "FuncQueueObject", to check for any problems with this soaksoak.ru problem that's hitting wp sites..

I found one instance of it, replaced that file with a clean one. and ran the grep command again:

[root@jazz ~]# grep -Rl "FuncQueueObject" /home/                                        

I got back this:
                     
/home/mysite/public_html/wp-includes/template-loader.php
[root@jazz ~]#

Even though I had removed the infection from that file. Double checking it, "FuncQueueObject" isn't there... but grep says it is... that's why I was thinking there must be a cache.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yep indeed, you're right - it was back. I had removed it but that didn't last long. I've removed it again and changed the permissions on that file to read only for all users. Hopefully that will do the trick.

Thanks for the help!