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.
Is there a good utility to find files when you have no idea exactly where they are? Secondly what does Linux use for wildcard chars in a search, for example in Windows you use * or ? , is it the same in Linux?
Wildcards:
* matches any number of chars, including none.
? matches one char.
The utilities to find files:
locate: requires an up-to-date database, which is built by the command updatedb. Then, if you know a string of letters of the filename (a regular expresion, or regex), the command is 'locate <string>' for a case sensive search for that string, and 'locate -i <string>' for a case in-sensitive search.
find: If you know part of the filename or part of the contents of the file, use the find command, and pipe it through grep to search in filenames and file contents.
find / -type f | grep <string>, where / begins the search at the root of the filesystem. You can reduce the search by giving the directory to search, as in 'find /home -type f | grep <string>' to restrict the search to the /home directory.
find / -type f | grep -i <string>, does the same except the search is case in-sensitive.
In the examples of find given above, the find command is piped through grep to search for the string.
For both commands, see the man pages: 'man locate' and 'man find' for more information.
Last edited by bigrigdriver; 05-15-2008 at 11:00 PM.
I would add a small clarification. There are two types of wild cards. The ? and * characters are used in the shell and for the -name argument of the find command. For real regular expressions ( used in grep, locate --regex, sed, etc. ) the dot (.) character is used instead of ?, and the * metacharacter means zero or more instances of the preceding charactor (or regular expression).
You can use the '-maxdepth 1' argument to control the levels of recursion (to 1 in this case). It seems like you haven't read the find man page yet. That will answer a lot of questions. The find command may be the most useful command you will use.
Last edited by jschiwal; 05-19-2008 at 08:02 AM.
Reason: fixed typo
Wildcards:
* matches any number of chars, including none.
? matches one char.
The utilities to find files:
locate: requires an up-to-date database, which is built by the command updatedb. Then, if you know a string of letters of the filename (a regular expresion, or regex), the command is 'locate <string>' for a case sensive search for that string, and 'locate -i <string>' for a case in-sensitive search.
find: If you know part of the filename or part of the contents of the file, use the find command, and pipe it through grep to search in filenames and file contents.
find / -type f | grep <string>, where / begins the search at the root of the filesystem. You can reduce the search by giving the directory to search, as in 'find /home -type f | grep <string>' to restrict the search to the /home directory.
find / -type f | grep -i <string>, does the same except the search is case in-sensitive.
In the examples of find given above, the find command is piped through grep to search for the string.
For both commands, see the man pages: 'man locate' and 'man find' for more information.
frank@c-75-75-174-33:~$ updatedb
bash: updatedb: command not found
frank@c-75-75-174-33:~$ man locate
No manual entry for locate
Last edited by Frank Soranno; 05-16-2008 at 10:13 AM.
Reason: Adding
Normally you need to be root to run updatedb. Most of us have it run as a cron job.
But...
It looks as though you do not locate installed
Consult your packagemanager. For my distro, locate comes as part of the findutils package
Thanks
I'm trying to on Debian forum right now, Got inpatient and tried this forum.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.