How to exclude a directory in find . command

后端 未结 30 1353
醉酒成梦
醉酒成梦 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:18

    You can also use regular expressions to include / exclude some files /dirs your search using something like this:

    find . -regextype posix-egrep -regex ".*\.(js|vue|s?css|php|html|json)$" -and -not -regex ".*/(node_modules|vendor)/.*" 
    

    This will only give you all js, vue, css, etc files but excluding all files in the node_modules and vendor folders.

提交回复
热议问题