Locate is limited in options, but you can still filter the results with other Linux commands, for example: grep. That’s the main options you’ll use (and probably only the first one).Īs you can see, locate is perfect when you know the file name and want a quick result, but not so useful in other cases. Only filenames containing the string, exclude matches in path name:.Will find any file name containing the word “syslog” There is no wildcard here, so this command: Find all file name containing your search pattern:.Here are three examples of what you can do: You never need sudo with this command, as the database is already created and updated with it. There are a few options, but it’s really simpler than find. The main goal with locate is to quickly find a file based on its name. Once done, you can now use locate directly. I think that this command is automatically done daily on your system, but you can schedule a task if you want to program it as you want. You can look at the manual page if you are interested in other options:įor example, you can execute a command on the results, display files only, disable recursive mode, etc.Will list all log files over 100M and not modified in the last month. Sudo find /var/log -size +100M -mtime +30
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |