查詢檔案或目錄指令

2021-10-20 07:28:03 字數 2924 閱讀 7950

linux 下find 指令可以查詢指定路徑下的檔案或路徑

find . -type f | grep ***   #-f 表示檔案  d 表示路徑  *** 表示檢索關鍵字

-h follow command line symlinks -l follow all symlinks

match filters:

-name pattern filename with wildcards (-iname case insensitive)

-path pattern path name with wildcards (-ipath case insensitive)

-user uname belongs to user uname -nouser user id not known

-group group belongs to group group -nogroup group id not known

-perm [-/]mode permissions (-=min /=any) -prune ignore dir contents

-size n[c] 512 byte blocks (c=bytes) -xdev only this filesystem

-links n hardlink count -atime n[u] accessed n units ago

-ctime n[u] created n units ago -mtime n[u] modified n units ago

-newer file newer mtime than file -mindepth n at least n dirs down

-depth ignore contents of dir -maxdepth n at most n dirs down

-inum n inode number n -empty empty files and dirs

-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)

-true always true -false always false

-context pattern security context -executable access(x_ok) perm+acl

-newerxy file x=acm time > file's y=acm time (y=t: file is literal time)

numbers n may be prefixed by a - (less than) or + (greater than). units for

-xtime are d (days, default), h (hours), m (minutes), or s (seconds).

grep -nre "keyword" . #在當前目錄下的所有檔案中檢索關鍵字keyword

grep --help

-e regex to match. (may be repeated.)

-f file listing regular expressions to match.

file search:

-r recurse into subdirectories (defaults file to ".")

-r recurse into subdirectories and symlinks to directories

-m match filename pattern (--include)

-s skip filename pattern (--exclude)

--exclude-dir=pattern skip directory pattern

-i ignore binary files

match type:

-a show num lines after -b show num lines before match

-c num lines context (a+b) -e extended regex syntax

-f fixed (literal match) -a always text (not binary)

-i case insensitive -m match max many lines

-v invert match -w whole word (implies -e)

-x whole line -z input nul terminated

display modes: (default: matched line)

-c count of matching lines -l show only matching filenames

-o only matching part -q quiet (errors only)

-s silent (no error msg) -z output nul terminated

output prefix (default: filename if checking more than 1 file)

-h force filename -b byte offset of match

-h hide filename -n line number of match

find 查詢檔案或目錄

find 查詢檔案或目錄 2007 12 18 10 50 02 分類 shell 舉報 字型大小 訂閱 功能說明 find指令可以在系統中查詢你想要的任何檔案或目錄,你可以通過不同的引數來查詢你想要的。該指令也是系統管理員最常用 最強大 最方便的查詢檔案和目錄的指令。基本語法 find path ...

find 查詢檔案或目錄

ind命令用來在指定目錄下查詢檔案。任何位於引數之前的字串都將被視為欲查詢的目錄名。如果使用該命令時,不設定任何引數,則find命令將在當前目錄下查詢子目錄與檔案。並且將查詢到的子目錄和檔案全部進行顯示。find 選項 引數 amin 分鐘 查詢在指定時間曾被訪問過的檔案或目錄,單位以分鐘計算 at...

Linux命令(七)查詢檔案或目錄 find

find 命令可以根據給定的路勁和表示式查詢指定的檔案或目錄。find 引數選項很多,並且支援正規表示式,功能強大。和管道結合使用可以實現複雜的功能,是系統管理和普通使用者必須掌握的命令。一 find 命令格式說明 path find命令查詢的目錄路徑。print find命令將匹配到的檔案輸出到標...