tags:

views:

23

answers:

1

I have a find command that I run, to find files named 'foo' in a directory. I want to skip the ".git" directory.

The command below works except it prints an annoying ".git" any time it skips a .git directory:

find . ( -name .git ) -prune -o -name '*foo*'

How can I prevent the skipped ".git" directories from printing to stdout?

A: 

Try this one:

find . -name '*foo*' | grep -v '\.git'

This will still traverse into the .git directories, but won't display them. Or you can combine with your version:

find . ( -name .git ) -prune -o -name '*foo*' | grep -v '\.git'

You can also do it without grep:

find . ( -name .git ) -prune -printf '' -o -name '*foo*' -print
petersohn
Okay -- I found that I don't have to put the -printf '' -- I only have to put the -print on the back of the command!For example, this works:find . \( -name .git \) -prune -o -name '*foo*' -printThanks!
Nathan Neff