Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Linux 中的 find 指令詳解

find 是 Linux 下相當強大且實用的指令,主要用於在檔案樹中搜尋符合條件的檔案。

基本語法

find pathname -options

常用選項

  • -name 依檔名搜尋。
  • -perm 依檔案權限搜尋。
  • -user 依檔案所有者搜尋。
  • -group 依檔案所屬群組搜尋。
  • -nogroup 找出無有效所屬群組的檔案,即該群組不存在於 /etc/groups。
  • -nouser 找出無有效所有者的檔案,即該所有者不存在於 /etc/passwd。
  • -type 依檔案類型搜尋:b 為塊設備、d 為目錄、c 為字符設備、p 為管道、l 為符號連結、f 為普通檔案。
  • -size n:[c] 搜尋長度為 n 個區塊的檔案,加上 c 時以位元組計。
  • -mtime 依修改時間搜尋。

實例演示

依檔名搜尋(-name)

Linux 中的 find 指令詳解

依檔案權限搜尋(-perm)

Linux 中的 find 指令詳解

依檔案所有者搜尋(-user)

Linux 中的 find 指令詳解

依檔案所屬群組搜尋(-group)

Linux 中的 find 指令詳解

找出無有效所有者的檔案(-nouser)

Linux 中的 find 指令詳解

搜尋某一類型的檔案(-type)

Linux 中的 find 指令詳解

依檔案長度搜尋(-size)

Linux 中的 find 指令詳解

搜尋 home 目錄下大於 4096 位元組、以及小於 4095 位元組的檔案:

Linux 中的 find 指令詳解

依修改時間搜尋(-mtime)。若從 Linux 的時間戳角度看,還有 -atime(最後一次存取時間)與 -ctime(權限最後一次變更時間)。

Linux 中的 find 指令詳解

本文出自「不斷進步的空間」部落格,請務必保留此出處 https://10824050.blog.51cto.com/10814050/1775175

Copyright © Linux教程網 All Rights Reserved