Linux Find 使用
find 基本用法 這邊介紹 find 尋找檔案或尋找資料夾的基本用法,在 Linux 或 macOS 下用 find 指令尋找檔案指令如下,例如要找 hello.txt 檔案的話,find 指令可以這樣用, $ find ./ -name "hello.txt" 如果要不區分大小寫的話,可以用 -iname 這個選項,像這樣用, $ find ./ -iname "hello.txt" 這樣不管是 hello.txt 或 Hello.txt 或 HELLO.txt 都可以找得出來, 如果想用 find 找包含 foo 關鍵字的檔案可以這樣用, $ find ./ -name "*foo*" 但 是這樣的結果會找出符合的檔案與資料夾,如果只想找出檔案不想找出資料夾的話可以另外加上 -type 選項,-type f 是找檔案,-type d 是找資料夾,預設都不加的話就是就是兩種結果都會列出來。 用 find 指令找當下目錄有包含 “foo” 關鍵字的 “檔案” 用法如下, $ find ./ -name "*foo*" -type f # -type f 找檔案 # -type d 找目錄 # 不加 -type 就是兩種結果都會列出來