Find a File (LINUX)

The find command allows you search for files according to various criteria.

find start_dir [options]

Options:

-user user Find files belonging to user (name or ID).

-cnewer file Find files that were changed after they were last modified.

-depth Descend the directory tree, skipping directories and working on actual files first, and then the parent directories.

-amin +n -n n Find files last accessed more than n (+n), less than n (-n), or exactly n minutes ago.

-anewer file Find files that were accessed after file was last modified.

-atime +n -n n Find files that were last accessed more than n (+n), less than n (-n), or exactly n days ago.

-cmin +n -n n Find files last changed more than n (+n), less than n (-n), or exactly n minutes ago.

-ctime +n -n n Find files that were changed more than n (+n), less than n (-n), or exactly n days ago.

-daystart Calculate times from the start of the day today, not 24 hours ago.

-maxdepth num Do not descend more than num levels of directories.

-mindepth num Begin applying tests and actions only at levels deeper than num levels.

-mmin +n -n n Find files last modified more than n (+n), less than n (-n), or exactly n minutes ago.

-mount, -xdev Search only for files that reside on the same filesystem as pathname.

-mtime +n -n n Find files that were last modified more than n (+n), less than n (-n), or exactly n days ago.

-empty Continue if file is empty.

-exec command{ } \ ; Run the Linux command, from the starting directory on each file matched by find (provided command executes successfully on that file—i.e., returns a 0 exit status).

-false Return false value for each file encountered.

-follow Follow symbolic links and track the directories visited (don't use with -type l).

-fstype type Match files only on type filesystems.

-gid num Find files with numeric group ID of num.

-group gname Find files belonging to group gname. gname can be a group name or a group ID number.

-ilname pattern A case-insensitive version of -lname.

-iname pattern A case-insensitive version of -name.

-inum n Find files whose inode number is n.

-ipath pattern A case-insensitive version of -path.

-iregex pattern A case-insensitive version of -regex.

-links n Find files having n links.

-lname pattern Search for files that are symbolic links, pointing to files named pattern. pattern can include shell metacharacters and does not treat / or . specially.

-name pattern Find files whose names match pattern.

-newer file Find files that were modified more recently than file; similar to -mtime.

-nogroup The file's group ID does not correspond to any group.

-noleaf Normally, find assumes that each directory has at least two hard links that should be ignored (a hard link for its name and one for "."--i.e., two fewer "real" directories than its hard link count indicates).

-noleaf turns off this assumption, a useful practice when find runs on non-Unix-style filesystems.

-nouser The file's user ID does not correspond to any user.

-ok command { }\; Same as -exec, but prompts user to respond with y before command is executed.

-path pattern Find files whose names match pattern.

-perm nnn Find files whose permission flags (e.g., rwx) match octal number nnn exactly (e.g., 664 matches -rw-rw-r--).

-regex pattern Like -path, but uses grep-style regular expressions instead of the shell-like globbing used in -name and -path.

-size n[c] Find files containing n blocks, or if c is specified, n characters long.

-type c Find files whose type is c. c can be b (block special file), c (character special file), d (directory), p (fifo or named pipe), l (symbolic link), s (socket), or f (plain file).

2 comments:

borisz said...

Long but very useful hope to see more of them, I found more interesting on net link http://www.softwaretipspalace.com/linux/index.html

Himmet said...

Usual man page description, supposing to getting hit?
Puah

Recent Posts