The find command is used to locate files on a Unix or Linux system. find will search any set of directories you specify for files that match the supplied search criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria. The search is recursive in that it will search all subdirectories too. The syntax looks like this:
find where-to-look criteria what-to-do
All arguments to find are optional, and there are defaults for all parts. (This may depend on which version of find is used. Here we discuss the freely available Gnu version of find, which is the version available on YborStudent.) For example, where-to-look defaults to . (that is, the current working directory), criteria defaults to none (that is, select all files), and what-to-do (known as the find action) defaults to ?print (that is, display the names of found files to standard output). Technically, the criteria and actions are all known as find primaries.
[root
@www ~]# find [PATH] [option] [action]
選項與參數:
1. 與時間有關的選項:共有 -atime, -ctime 與 -mtime ,以 -mtime 說明
-mtime n :n 為數字,意義為在 n 天之前的『一天之內』被更動過內容的檔案;
-mtime +n :列出在 n 天之前(不含 n 天本身)被更動過內容的檔案檔名;
-mtime -n :列出在 n 天之內(含 n 天本身)被更動過內容的檔案檔名。
-newer file :file 為一個存在的檔案,列出比 file 還要新的檔案檔名
範例一:將過去系統上面 24 小時內有更動過內容 (mtime) 的檔案列出
[root
@www ~]# find / -mtime 0
# 那個 0 是重點!0 代表目前的時間,所以,從現在開始到 24 小時前,
# 有變動過內容的檔案都會被列出來!那如果是三天前的 24 小時內?
# find / -mtime 3 有變動過的檔案都被列出的意思!
範例二:尋找 /etc 底下的檔案,如果檔案日期比 /etc/passwd 新就列出
[root
@www ~]# find /etc -newer /etc/passwd
# -newer 用在分辨兩個檔案之間的新舊關係是很有用的!
http://linux.vbird.org/linux_basic/0220filemanager.php#find
http://content.hccfl.edu/pollock/unix/findcmd.htm