Exclude a sub-directory using find

前端 未结 6 1871
鱼传尺愫
鱼传尺愫 2021-01-30 18:54

I have directory structure like this

data
|___
   |
   abc
    |____incoming
   def
    |____incoming
    |____processed
   123
    |___incoming
   456
    |___i         


        
6条回答
  •  醉话见心
    2021-01-30 19:51

    This works:

    find /home/feeds/data -type f -not -path "*def/incoming*" -not -path "*456/incoming*"
    

    Explanation:

    • find /home/feeds/data: start finding recursively from specified path
    • -type f: find files only
    • -not -path "*def/incoming*": don't include anything with def/incoming as part of its path
    • -not -path "*456/incoming*": don't include anything with 456/incoming as part of its path

提交回复
热议问题