Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So I'm trying to find all the mercurial repositories in my home directory

$ find ~ -name ".hg" -or -name ".git"

This works fine, but it finds a lot in the ~/.local/share/Trash subdirectory

How do I make it ignore these? Obviously there's grep -v, but it would be better not to search Trash at all.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can use the -prune option this way:

find ~ -path '*Trash*' -prune -or -name ".hg" -or -name ".git"
share|improve this answer
    
awesome thanks! –  John Lawrence Aspden Mar 27 '11 at 16:32
    
This really works? For me it doesn't prune all the different files with the string Trash in it; also this is looking for files with the exact name ".hg"; shouldn't it be something like *.hg? –  arrange Mar 27 '11 at 16:48
    
@arrange, I take the example from the user asking the question, and modified that. And, obviously, it works for me that have done some tests. –  enzotib Mar 27 '11 at 17:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.