1

I'm doing a word search using the following command:

find . -exec grep -q [some_word]  '{}' \; -print -o -name .svn -prune -o -name .ssh -prune -o -name .boneyard -o -name log -prune -prune -o -name tmp -prune

Is it possible to use a regex to exclude all hidden directories?

Note: The current command traverses the entire tree from the current location and exclude those being pruned. The exclusion needs to work for any hidden directory regardless off location.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311

1 Answers1

0

You want the regex flag of find:

find . \( ! -regex '.*/\..*' \) -exec grep -q [some_word] {} \; -print -o -name .svn -prune -o -name .ssh -prune -o -name .boneyard -o -name log -prune -prune -o -name tmp -prune

Also, please read the manual.

slhck
  • 235,242