Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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'm trying to search for a particular entry in a file somewhere on my system and I noticed that 'find' appears stuck on a particular file - /proc/kmsg.
I used the following syntax to search for my text:
Distribution: Anything NOT SystemD (ie. M$) related.
Posts: 918
Rep:
locate is good but you need to make sure it is kept updated with cron or you have to continueally 'updatedb' whenever you add/delete anything.
also you need to make sure you have all the partitians mounted that you want 'considered' in the index (and not stuff like archives and backups) which may be repetitious and time consuming to index.
the locate and updatedb config files are your friends.
The reason why the find command hung when searching for some text within /proc/kmsg
is that this is a special file, mainly used by klogd to access system messages. A read
of /proc/kmsg will never end -- you can read more about it in the kernel documentation
in (probably) /usr/src/linux/Documentation/oops-tracing.txt if you have the kernel source installed.
Because /proc contains special files that only provide information about, and control of, processes
and devices, you probably don't want to even bother looking at those files when searching your filesystem for files that contain some text of interest to you. So the simplest remedy is to use find's "-prune" option to omit that whole filesystem subtree from the search.
I had to correct a few typos to find what I wanted: -name (twice) should be -path and -type should be preceded by another -o. Now it's REAL handy
Glad it has helped you out. I use it all the time. What I pasted above is exactly how I use it on my system and it works fine. Can you post what mods you did. i would be interested seeing it.
you may want to try locate
it builds a db of all the files on your system
then you can just locate file_name
locate will not do what was originally asked here. Locate will find a file with a match in the "filename"
What this thread is about is searching for a string INSIDE of files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.