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 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
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
find . -type d -name "*-old" -prune -o -name "*.cpp" -print
share|improve this answer

You must log in to answer this question.

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