0

I need to copy a few files to another directory. The source structure is as follows

src/foo1.h
src/foo2.h
src/bar/foobar.h

I need to copy these so they end up here

/usr/include/foo/foo1.h
/usr/include/foo/foo2.h
/usr/include/foo/bar/foobar.h

In Linux I use cp -u --parents *.h bar/*.h /usr/include/foo from src, which works great. However, I can't find a suitable replacement in Mac OSX - cp doesn't support parents or an equivalent option, and install supports -d which is supposed to preserve the structure, but gives me the following error: install: foo1.h exists but it's not a directory

I'm stuck. Any ideas?

ggambetta
  • 3,312
  • 6
  • 32
  • 42

1 Answers1

1

You could use rsync, e.g.

rsync -a ./src/ /usr/include/foo/ --include \*/ --include \*.h --exclude \*

BTW, you probably don't want to install stuff to /usr/include, as it may well get clobbered by system updates. Consider using e.g. /usr/local/include instead.

Paul R
  • 208,748
  • 37
  • 389
  • 560