When the -L option is in effect, the -type predicate always matches against the type of the file that a symbolic link points to rather than the link itself (unless the symbolic link is broken). If -L is in effect and find discovers a symbolic link to a subdirectory during its search, the subdirectory pointed to by the symbolic link is searched. If you later use the -P option, -noleaf is still in effect. When find examines or prints information about files, the information used is taken from the properties of the file that the link points, not from the link itself (unless it is a broken symbolic link or find cannot examine the file that the link points). When find examines or prints information a file, and the file is a symbolic link, the information used is taken from the properties of the symbolic link itself.įollow symbolic links. " or " /" is generally safer if you use wildcards in the list of start points). A double-dash (" -") can also be used to signal that any remaining arguments are not options (though ensuring that all start points begin with either ". The arguments in the expression list are also referred to as "options," but the five "real" options -H, -L, -P, -D and -O must appear before the first path name, if they are used at all. If no expression is given, the expression -print is used (but consider using -print0 instead. If no paths are given, the current directory is used. That argument and any following arguments are taken to be the expression describing what is being searched. Arguments following these are taken to be names of files or directories to be examined, up to the first argument that begins with " -", or the argument " (" or " !". The -H, -L and -P options control the treatment of symbolic links. It can be used on its own to locate files, or in conjunction with other programs to perform operations on those files. At that point find moves on to the next path until all paths are searched.įind is a fundamental and extremely powerful tool for working with the files on your linux system. The outcome is "known" when the left side of the expression is determined to be FALSE for AND operations, or TRUE for OR operations. Within each directory tree specified by the given paths, it evaluates the given expression from left to right, according to the rules of precedence (see " Operators", below) until the outcome is known. Suppressing Error Messages When Using findįind locates files on your system.These cron jobs need to be configured by root, since updatedb needs root privileges to traverse the whole filesystem. To see the full list of locate's options, type:Īdditionally, you can configure locate to update its database on scheduled times via a cron job, so a sample cron which updates the database at 1 AM would look like: 0 1 * * * updatedb It will look through its database of files and quickly print out path names that match the pattern that you have typed. Or, to look for a filename or pattern from within the current directory, you can type: pwd | xargs -n 1 -I locate "filepattern" If the install script doesn't do it for you, it can be done manually by typing sudo updatedbĪnd, to use it to look for some particular file, type: locate filename You should check the manual of your OS on how to install it, and once it's installed, it needs to initiate the database. One such common tool is locate or slocate/mlocate. However, there are more modern and faster tools than find, which are traversing your whole filesystem and indexing your files. Or if man pages aren't available at your system: find -help To see the full list of options, type man find With the find command, you can use wildcards, and various switches. It starts recursively traversing for filename or pattern from within the current directory where you are positioned. The default way to search for files recursively, and available in most cases is find.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |