1.find查詢概述
為什麼要有檔案查詢,因為很多時候我們可能會忘了某個檔案所在的位置,此時就需要通過find來查詢。
find命令可以根據不同的條件來進行查詢檔案,例如:檔名稱、檔案大小、檔案修改時間、屬主屬組、許可權、等等方式。同時find命令是linux下必須掌握的。
find 命令的基本語法如下
命令 路徑 選項 表示式 動作
find [path...] [options] [expression] [action]
查詢 地區 妹紙 18-25歲 約?
2.find查詢示例
以下列出所有find常用的選項
1.find名稱查詢
touch /etc/sysconfig/network-scripts/
[root@xuliangwei ~]# find /etc -name "ifcfg-eth1"
[root@xuliangwei ~]# find /etc -iname "ifcfg-eth1"
[root@xuliangwei ~]# find /etc/ -name "ifcfg-eth"
[root@xuliangwei ~]# find /etc -iname "ifcfg-eth"
2.find大小查詢
[root@xuliangwei ~]# find /etc -size +5m
[root@xuliangwei ~]# find /etc -size 5m
[root@xuliangwei ~]# find /etc -size -5m
3.find型別查詢
[root@xuliangwei ~]# find /dev -type f
[root@xuliangwei ~]# find /dev -type d
[root@xuliangwei ~]# find /dev -type l
[root@xuliangwei ~]# find /dev -type b
[root@xuliangwei ~]# find /dev -type c
[root@xuliangwei ~]# find /dev -type s
[root@xuliangwei ~]# find /dev -type p
4.find時間查詢
[root@xuliangwei ~]# for i in ;do date -s 201904\(i && touch file-\)i;done
[root@xuliangwei ~]# find ./ -iname "file-*" -mtime +7
[root@xuliangwei ~]# find ./ -iname "file-*" -mtime -7
[root@xuliangwei ~]# find ./ -iname "file-*" -mtime 7
find /backup/ -iname ".bak" -mtime +7 -delete
find /backup/ -iname ".bak" -mtime +90 -delete
5.find使用者查詢
[root@xuliangwei ~]# find /home -user jack
[root@xuliangwei ~]# find /home -group admin
[root@xuliangwei ~]# find /home -user jack -group admin
[root@xuliangwei ~]# find /home -user jack -a -group admin
[root@xuliangwei ~]# find /home -user jack -o -group admin
[root@xuliangwei ~]# find /home -nouser
[root@xuliangwei ~]# find /home -nogroup
[root@xuliangwei ~]# find /home -nouser -o -nogroup
6.find許可權查詢
[root@xuliangwei ~]# find . -perm 644 -ls
[root@xuliangwei ~]# find . -perm -444 -ls
[root@xuliangwei ~]# find . -perm -222 -ls
[root@xuliangwei ~]# find /usr/sbin -perm -4000 -ls
[root@xuliangwei ~]# find /usr/sbin -perm -2000 -ls
[root@xuliangwei ~]# find /usr/sbin -perm -1000 -ls
2.find動作處理,比如查詢到乙個檔案後,需要對檔案進行如何處理, find的預設動作是 -print
動作 含義
-print 列印查詢到的內容(預設)
-ls 以長格式顯示的方式列印查詢到的內容
-delete 刪除查詢到的檔案(僅能刪除空目錄)
-ok 後面跟自定義 shell 命令(會提示是否操作)
-exec 後面跟自定義 shell 命令(標準寫法 -exec
linux檔案查詢
命令與檔案的查詢 which 尋找執行檔案 which a command a 將所有由path目錄中可以找到的命令均列出來,而不只是第乙個被找到的命令名稱 eg which a ifconfig 檔案的查詢 whereis 尋找特定的檔案 bmsu 檔案或者目錄 引數 b 只尋找二進位制檔案 m ...
linux 檔案查詢
文字查詢 grep egrep fgrep 檔案查詢 locate find locate和find的區別 locate有自維護的資料庫 linux自建,與所有檔案關聯 每天linux會定時對其進行更新,而locate就在此資料庫中查詢,所以查詢速度非常快,但是缺點也很明顯,不能實時查詢 比如剛裝l...
Linux 檔案查詢
檔案查詢 簡介which 命令查詢 find 檔案查詢,針對檔名 locate 檔案查詢,依賴資料庫 一 命令檔案查詢 一 查詢ls 命令的位置 which ls 從path環境變數或者 whereis vim二 任意檔案 find 語法find path options expression ac...