the command 'grep' is so slow
I use the command 'grep' to search files that contains 'switchdesk.png' from the starting point '/', but it's too slow and have no messages like windows which shows where the searching process is.So I press Ctrl+c to stop the searching process.But where is the files I want to find ?:confused:
|
If you're running grep over a very large number of files it will be slow because it needs to open them all and read through them. If you have some idea of where the file you're looking for might be try to limit the number of files that have to be searched through that way.
On the other hand you may be using it wrong and it may be sitting there doing nothing. Please post the exact grep command you used and what you expect it to do. Tim |
Or if you are just trying to find switchdesk.png (e.g. it is a file not a line within a file) try: "locate switchdesk.png"
|
I use the command:
'grep -r switchdesk.png *' |
Quote:
Note that this is not the same as searching for a file whose name is "switchdesk.png". That you can do with this command : find . -name 'switchdesk.png' This will be much faster, but its not doing the same thing. Tim |
I made a experiment .I create a file called 123.txt that contains 'switchdesk.png',and I use the command 'grep -r switchdesk.png / *' .
And now I am waiting for the result ,but I can see nothing on the screen except the flashing cursor.:confused: |
You don't want the / before *, that's telling it to search through the whole filesystem !
The command you want is : grep -r switchdesk.png * Tim |
I know it ,but I wonder if there is an option the command 'grep' can use to search the whole filesystem quickly and effectively(like windows) or not!
|
How exactly would you search through the whole filesystem quickly and effectively in Windows ?
Remember we are talking about searching in the contents of files, not just for filenames. Tim |
why don't you just rebuild your locate or slocate db and then locate that file.
as su slocate -uc that will rebuild the db from the / then as user slocate whateverfile you'll get what your looking for. |
What is the actual difference between locate and slocate? Every help file and piece of documentation on them seems to be the same. Are they just aliases for the same thing?
|
I think locate showed everything on the system and slocate just shows what a user has access to. Maybe some other changes. 'S'ecure 'locate'. Locate was insecure, basically. And locate is a symlink to slocate now, anyway.
|
I have to comment on the Windows issue you mention - Searching for specific info within a file through the entire filesystem on Windows is not faster than using the grep command to perform the similar operation - at least not mentionable... haven't tried to perform regular benchmarks though... and don't think you fairly could. But I tried it in regular use and found no difference as such.
|
Quote:
find / -exec grep -l 'switchdesk.png' {} \; Might be quicker. |
All times are GMT -5. The time now is 02:57 PM. |