日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux find prune排除某目录或文件

發布時間:2023/12/1 linux 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux find prune排除某目录或文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

http://blog.csdn.net/ysdaniel/article/details/7995681

查找cache目錄下不是html的文件

  • find ./cache ! -name '*.html' -type f
  • 列出當前目錄下的目錄名,排除includes目錄,后面的-print不能少

  • find . -path './includes' -prune -o -type d -maxdepth 1 -print
  • 排除多個目錄,”(“前是帶”\”的

  • find / \( -path /home/ -o -path /root \) -prune -nouser -type f -exec ls -l {} \;
  • ?

    find查找文件的時候排除某個或幾個文件或目錄

    比如要在/usr/sam目錄下查找不在dir1子目錄之內的所有文件

    ?

    find /usr/sam -path "/usr/sam/dir1" -prune -o -print

    ?

    ?

    find [-path ..] [expression] 在路徑列表的后面的是表達式

    ?

    -path "/usr/sam" -prune -o -print 是 -path "/usr/sam" -a -prune -o -print 的簡寫表達式按順序求值, -a 和 -o 都是短路求值,與 shell 的 && 和 || 類似如果 -path "/usr/sam" 為真,則求值 -prune , -prune 返回真,與邏輯表達式為真;否則不求值 -prune,與邏輯表達式為假。如果 -path "/usr/sam" -a -prune 為假,則求值 -print ,-print返回真,或邏輯表達式為真;否則不求值 -print,或邏輯表達式為真。

    這個表達式組合特例可以用偽碼寫為

    ?

    if -path "/usr/sam" then
    ?????????? -prune
    else
    ?????????? -print

    ?

    避開多個文件夾

    ?

    find /usr/sam \( -path /usr/sam/dir1 -o -path /usr/sam/file1 \) -prune -o -print

    ?

    圓括號表示表達式的結合。

    \ 表示引用,即指示 shell 不對后面的字符作特殊解釋,而留給 find 命令去解釋其意義。

    ?

    查找某一確定文件,-name等選項加在-o 之后

    ?

    #find /usr/sam \(-path /usr/sam/dir1 -o -path /usr/sam/file1 \) -prune -o -name "temp" -print

    ?

    linux下的常用命令find,加上不同的參數,可以使你很容易的找到需要的文件,但是有些時候,你在查找文件的同時,可能不需要在某文件夾下查找,這時候-prune就用上了。

    比如在當前目錄下尋找pl后綴的文件,不在scripts下尋找。

    find . -path './scripts' -prune -o -name '*.pl' -print

    轉載于:https://www.cnblogs.com/baiyw/p/3525761.html

    總結

    以上是生活随笔為你收集整理的linux find prune排除某目录或文件的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。