The power of findįind becomes extremely useful when combined with other commands. The "!" allows you to exclude results that contain the phrases following it. name '*foo*' ! -name '*.bar' -type d -print Several types of files can be searched for:ĭ door (Solaris) Search for directories that contain the phrase "foo" but do not end in ".bar" Similar criteria are -uid to search for a user by their numerical id, -group to search by a group name, and -gid to search by a group id number. The files output will belong to the user "joebob". $ find /some/directory -user joebob -print Search for files that are owned by the user "joebob" Search directories "./dir1" and "./dir2" for a file "foo.bar" bar, within the current directory and only search 2 directories deep The 2>/dev/null option sends these messages to /dev/null so that the found files are easily viewed. When find tries to search a directory or file that you do not have permission to read the message "Permission Denied" will be output to the screen. $ find / -name foo.bar -print 2>/dev/null Find a file without showing "Permission Denied" messages "-mount" does the same thing as "-xdev" for compatibility with other versions of find. This can increase search speed greatly if the mounted filesystem is large or over a slow network. This is useful if you have mounted network drives or filesystems that you do not want searched. Find a file without searching network or mounted filesystems Without specifications find searches recursively through all directories. On most platforms the -print is optional, however, on some Unix systems nothing will be output without it. If the file is found the path to the file will be printed as output. Examples Find a file "foo.bar" that exists somewhere in the filesystem The find command is a powerful *nix utility that allows the user to find files located in the file system via criteria such as the file name, when file was last accessed, when the file status was last changed, the file's permissions, owner, group, size, or even number of inodes.
0 Comments
Leave a Reply. |