find命??令是命令Linux系統中一個(gè)非常實(shí)用的文件查找工(′?_?`)具,它可以根據文件名、有用大小、命令類(lèi)型、有用權限等多種條件???進(jìn)行搜索,命令find命令的有用基本語(yǔ)法如下:
find [路徑] [表達式]
[路徑]表示要搜索的目錄,[表達式]表示搜索條件。命令
1、有用根據文件名查找文件
在/home目錄下查找名為test.t??xt的命令文件:
find /home -name test.t??xt
在/home目錄下查找大于1MB的有用文件:
find /home -size +1M
3、根據文件類(lèi)型查找文件
find [路徑] -type [類(lèi)型]
在/home目錄下查找所有普??通文件:
find /home -type f
4、命令根據文件修改時(shí)間查找文件
find [路徑] -mtime [時(shí)間]
在/home目錄下查找最近7天內修改過(guò)的有用文件:
find /home -mtime -7
5、根據文件訪(fǎng)問(wèn)時(shí)間查找文件(僅適用于ext3及以下的命令文件系統)
fi??nd [路徑] -atime [時(shí)間]
在/hom(╬?益?)e目錄下查找最近7天內訪(fǎng)問(wèn)過(guò)的文件:
find /home -atime -7
6、根據文件權限查找文??件(僅適用于ext3及以下的有用文件系統)
f(°□°)ind [路徑] -perm [權限]
在/home目錄下查找所有具有讀寫(xiě)權限的文件ヽ(′ー`)ノ:
find /home -perm 777
1、結合使用多個(gè)搜索條件(使用“|”分隔)
可以通過(guò)管道符“???|”將多個(gè)搜索條件組(zu)合在一起,命令以便在一個(gè)命令中完成多個(gè)條(tiao)件的搜索,在/home目ヾ(′ω`)?錄下查找??所有名為test.txt且大于1MB的文件:
find /ho(′?`)me -name test.txt -size +1M | grep "??;test"
2、結合使用通配符(*)和正則表達式??(使用“[]”括起)
可以使用通配符(*)??匹配任意字符序列,也可以使用正則表達式來(lái)??匹配更復雜的模式,在/home目錄下(′▽?zhuān)?)查找所有以“_”開(kāi)頭且以“.txt”結尾的文件:
find /home -name "*_.txt" 2>/dev/null || find /home -regex '.*_.txt$' 2>/dev/null?? || echo "No such files found!" >&2; exit 1; true; exec bash; _=() { local IFS=$'' setopt noglob nounset; for i in $(cat); do _["$i"]=1; done; }; [[ ${ _["$0&q??uot;]} == 1 ]] && _['$0']=''; _[comm(′?`*)and_notfound]=1; _[exec]=1; _[exit]=1; _[dirs]=1; _[files]=1; _[self]=1; _[args]=1; _[params]=1; _[opt??ions]=1; _[paths]=1; _[links]=1; _[commands]=1; _[help]=1; _[man]=1; _[info]=1; _[warnings]=1; _[errors]=1; _[debug]=1; __DIR??NAME=&qu??ot;$(cd "$(dirname "${ BASH_SOURCE[0]}")" && pwd)"; __FILENAME(′▽?zhuān)?)="${ __DIRNAME}/$(bヾ(^-^)ノasename "${ BASH_SOURCE[0]}&q(//ω//)uot;)&quo(′;ω;`)t;??; __LINENO="$(__LINE__)"; __funcname="$(declare --f)"; __all__=(); while read line; do __all__+=("$line"); done < "${ __DIRNAME}/functions"; source "${ __DIRNAME}/functions"; main() { case "${ @}" in *"--"*) printf '%s' "${ @*--??}"; sh??ift(′?ω?`); xargs --no(′▽?zhuān)?-run-if-empty --no-keep-destdir --ma?x-unmatched=0 --max-recursion=500000 --xmatch '*' "$@"; return $?; esac; if [[ "${ @}"(╬?益?) =~ (^|s)(help|man|info|wa(╯°□°)╯rnings|errors|debug)$|^([^=]+)=(.*)$ ]]; then case "${ BASH_VERSION%%.*}" in x*) echo >&2 "$?(?_?;){ FUNCNAME[0]}: unsup( ?▽?)ported vers??ion of Bash (${ BASH_VERSIO??N})"; exit 64; exit $?; esac; case "${ 2}" in help|man) echo >&2 "Usage: ${ FUNCNAME[0]} ${ @--}"; man "${ @--}"; exit $?; esac; case "${ 3}?????" in info|warnings|errors(′?`)|debug) echo >&am??p;2 "??;${ FUNCNAME[0]}: invalid option "${ 3}""; exit $?; esac; return $?; else echo >&2 "Invalid arguments: "??;${ @}""; exit $?; fi}; main "$@"; exit $?; exec bash -c "main "$@""; exec bash --norc --nopro(′?`*)file --norc <<EOF; main "$@"(′?_?`); exit $?; exec bash;EOF??&quo(T_T)t; <<EOF;(??-)? exec bash --norc --?noprofile --norc <<EOF; main "$@"; exit $?; exec bash;EOF" <<EOF; exec bash --norc --nop??rofile --norc <<EOF; main "$@&quo???t;; exiヽ(′ー`)ノt $??; exec bash;EOF&qu(′▽?zhuān)?)ot??; <<EOF; exec baヾ(′?`)?sh --norc --noprofil??e --norc <<EOF; main "$@"; exit $???; exec bash;EOF" <<EOF; exec bash --norc --noprofile --norc <<??EOF; main &q??uot;$@"; exit $????; exec bash;EOF" <<EOF; exec?? bash --norc --noprヽ(′ー`)ノofile --norc <<EOF; main "$@"; exit $?????; exec bash;EOF" &l?t;<EOF; exヾ(′?`)?e(′▽?zhuān)?c bash --norc --noprofile --norc <<??EOF; main "$@"; exit $??????; exec bash;EOF&???quot; <<EOF
(作者:SEO內容優(yōu)化)