V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
coderabbit
V2EX  ›  Linux

Linux find 查找文件 过滤掉不查找的目录与文件。

  •  
  •   coderabbit · Apr 26, 2019 · 5936 views
    This topic created in 2562 days ago, the information mentioned may be changed or developed.

    Linux find 查找文件 过滤掉不查找的目录与文件。。

    6 replies    2020-01-21 16:20:01 +08:00
    itabas016
        1
    itabas016  
       Apr 26, 2019 via Android
    man find
    CallMeReznov
        2
    CallMeReznov  
       Apr 26, 2019
    mrsatangel
        3
    mrsatangel  
       Apr 26, 2019   ❤️ 1
    find [pattern] ! -path "[exclude_dir1]/*" ! -path "[exclude_dir2]/*"
    coderabbit
        4
    coderabbit  
    OP
       Apr 26, 2019
    @CallMeReznov

    ```
    find . ! -path "./manage/*" ! -path "./vendor/*" -name "*.js" -o -name "*.css"
    ```

    结果
    ```
    ./index.js
    ./index.css
    ./vendor/fontawesome/all.min.css
    ```

    vendor 目录没有被排除干净 find

    后来看到有个深度限制 排除干净了!

    ```
    find . -maxdepth 1 -type f ! -path "./manage/*" ! -path "./vendor/*" -name "*.js" -o -name "*.css"
    ```
    CallMeReznov
        5
    CallMeReznov  
       Apr 26, 2019
    idemaker
        6
    idemaker  
       Jan 21, 2020
    find . ! -path "./shangcheng/*" \( -name "*.css" -o -name "*.js" \)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2452 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 04:14 · PVG 12:14 · LAX 21:14 · JFK 00:14
    ♥ Do have faith in what you're doing.