Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
    
I tried this and various other methods and couldn't get the output to match. I see now my problem is with 'grep -q'. Thanks for the quick response. – xRickerlx Jun 27 '12 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .