How does the linux command match the multi-tier folder path?

requirements: want to match all JS files under folder A (including infinite recursive subdirectories), but not js files under a directory called node_modules descendants.
the current practice is to iterate through the nodeJS folder layer by layer to determine the directory folder name.

feels like it should be done with a linux command, but it"s not written.

could you tell me how to write all the great gods?

Nov.22,2021

find -name '*.js' -not -path '*/node_modules/*'

match multiple files:

find \( -name '*.js' -o -name '*.vue' -o -name '*.jsx' \) -not -path '*/node_modules/*'

of course, you can also match so many suffixes with regular expressions:

find -regextype posix-extended -regex '.*\.(js|vue|jsx)$' -not -path '*/node_modules/*'

find defaults to BRE regularity. Because this expression uses | selection structure, which is not supported by BRE , you must use ERE compatible rules. So you must specify regextype as the posix extension regular to support this regular query


find /A | perl -nle 'print if /^(((?!\/node_modules\/).)*\/((?!\/).)*?\.js)$/'
Menu