How to exclude a directory in find . command

后端 未结 30 1976
醉酒成梦
醉酒成梦 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条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 03:57

    You can use the prune option to achieve this. As in for example:

    find ./ -path ./beta/* -prune -o -iname example.com -print
    

    Or the inverse grep “grep -v” option:

    find -iname example.com | grep -v beta
    

    You can find detailed instructions and examples in Linux find command exclude directories from searching.

提交回复
热议问题