Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a source tree having some directories with names ending with -old, which are kept as a reference when rewriting components that are in them. There's also a Makefile that just finds all *.cpp files in subfolders of current directory and compiles them into single executable (yes, I know, it ain't any great build system, but it works quite fine... except the -olds).

So, I am using this to get list of all *.cpp files:

SOURCES=$(shell find . -name "*.cpp" -print)

How can I tell find to look for all *.cpp files, that do not have *-old* in their path?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

$ find . -type f -name '*.cpp' ! -path '*-old*'
share|improve this answer
    
Ok, obviously. I have no idea why I didn't come up with this. Thanks. –  Griwes Apr 20 '13 at 16:51
add comment
find . -type d -name "*-old" -prune -o -name "*.cpp" -print
share|improve this answer
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.