Skip to content

Instantly share code, notes, and snippets.

@joeyfigaro
Created April 6, 2021 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeyfigaro/9fcf579ec0d08afc4277d1998dc582f4 to your computer and use it in GitHub Desktop.
Save joeyfigaro/9fcf579ec0d08afc4277d1998dc582f4 to your computer and use it in GitHub Desktop.
['find' with path filtering] Find target files while ecluding a set of specified directories #osx #find #monorepos #commandline
find / -name MyFile ! -path '*/Directory/*'

Example

Find all package.json files in monorepo packages (excluding node_modules/* and specific package location)

find . -name 'package.json' ! -path '*/node_modules/*' ! -path '*/prisma/generated/*'

Find and copy

find . -name 'package.json' ! -path '*/node_modules/*' ! -path '*/prisma/generated/* | \
xargs cp --parents -t ../manifests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment