How to exclude a directory in find . command

后端 未结 30 1409
醉酒成梦
醉酒成梦 2020-11-22 03:36

I\'m trying to run a find command for all JavaScript files, but how do I exclude a specific directory?

Here is the find code we\'re using.<

30条回答
  •  被撕碎了的回忆
    2020-11-22 04:04

    The -path -prune approach also works with wildcards in the path. Here is a find statement that will find the directories for a git server serving multiple git repositiories leaving out the git internal directories:

    find . -type d \
       -not \( -path */objects -prune \) \
       -not \( -path */branches -prune \) \
       -not \( -path */refs -prune \) \
       -not \( -path */logs -prune \) \
       -not \( -path */.git -prune \) \
       -not \( -path */info -prune \) \
       -not \( -path */hooks -prune \)  
    

提交回复
热议问题