Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ?
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.
Originally posted by domeili I use the command:
'grep -r switchdesk.png *'
OK this command will for search for the string "switchdesk.png" within all of the files in the directory you are in and all of its subdirectories and sub-subdirectories etc. If the directory hierarchy contains a lot of data, expect it to take a while.
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.
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.
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.
Originally posted by domeili 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!
I don't know about quick and effective (its all relative) but you could try
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.