tags:

views:

23

answers:

1

I am trying to find all ruby files in the project. However I want to ignore all the files residing under directory vendor.

find . -name .vendor -prune -o -name '*.rb' -print

Above command is not working. Anyone knows the fix?

+1  A: 

Try:

find . -name '*.rb' ! -wholename "./vendor/*" -print

You may have to escape ! (i.e. write \!) character depending on your shell.

pajton
I am using bourne shell and it worked just fine. thanks
Nadal
find . -name '*.rb' ! -wholename "./vendor/*" | ack vendorworks. However find /Users/dorelal/dev/working/demo_app -name '*.rb' ! -wholename "./vendor/*" | ack vendor is not working. Any idea why?
Nadal
not working means even the .rb files under vendor directory are showing up.
Nadal
`! -wholename <pattern>` means to exclude every path that matches <pattern>. When you exec `find .` every path starts with `./`. when you exec `find /path/to/sth` every path `find` reports starts with `/path/to/sth`. So you'd need to change pattern to `*/vendor/*` or `/path/to/sth/vendor/*`.
pajton
Did that help:)?
pajton
got it. Thanks.
Nadal
pajton, you find junkie ;-)
gruszczy