find 查找

find查找
(1)根據(jù)文件名,類型查找
[root@lsr7 ~]# find / -type d -name 'ip' //查找/下面類型是目錄,名字是ip的
/usr/src/kernels/3.10.0-957.5.1.el7.x86_64.debug/include/config/ip
/usr/src/kernels/3.10.0-957.5.1.el7.x86_64.debug/include/config/net/ip

[root@lsr7 ~]# find oldboy -type f -name '*.txt' //查看oldboy目錄,里面以txt為結(jié)尾的文件
find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments. //警告信息-maxdepth要放在前面
(2)根據(jù)-maxdepth(文件深度查找)
[root@lsr7 oldboy]# find / -maxdepth 1 -type d //-maxdepth(最多深度)1層次是1 -type d類型是目錄
/
/dev
/home
/proc
/run
/sys
[root@lsr7 ~]# find /etc/ -maxdepth 1 -type f -iname .conf //找出/etc/目錄下面第1層目錄中以.conf結(jié)尾的文件(不區(qū)分大小寫)(mai si di pai te)
/etc/resolv.conf
/etc/libaudit.conf
(3)! 取反
[root@lsr7 ~]# find /etc/ -type f ! -iname '
.conf' //查找/etc/目錄下除了conf的其它文件(不區(qū)分大小寫)
/etc/zlogout
/etc/zprofile
/etc/zshenv
(4)size 根據(jù)大小查找文件
[root@lsr7 ~]# find /etc/ -size +1M //查找/etc/下大于1M的文件
[root@lsr7 ~]# find /etc/ -size -5k //查找/etc/下小于5k的文件

  1. xargs分組(只有xargs和tr用<)
    [root@lsr7 ~]# echo {A..Z} > oldboy/huahua.txt
    [root@lsr7 ~]# cat oldboy/huahua.txt
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    [root@lsr7 ~]# xargs -n5 < oldboy/huahua.txt
    A B C D E
    F G H I J
    K L M N O
    P Q R S T
    U V W X Y
    Z
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容