Exclude a sub-directory using find

前端 未结 6 1873
鱼传尺愫
鱼传尺愫 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:35

    This is what I did to exclude all the .git directories and passed it to -exec for greping something in the

    find . -not -path '*/\.*' -type f -exec grep "pattern" [] \;
    
    • -not -path '*/\.*' will exclude all the hidden directories
    • -type f will only list type file and then you can pass that to -exec or whatever you want todo

提交回复
热议问题