I have a following directory structure for my code containing *.c ad *.h files and some configuration and build files generated by automake & autoconf I want to copy only the *.c and *.h files into new directory structure like this

testdir/
├── subtest1
│   └── subtest11
│       ├── test111.c
│       └── test111.h
└── subtest2
    └── test.c

newtestdir/ <--------------------- ONLY THIS DIRECTORY IS CHANGED !!
├── subtest1
│   └── subtest11
│       ├── test111.c
│       └── test111.h
└── subtest2
    └── test.c

Any hints as to how to do this on Linux ???

Thanks for the gr8 work of sharing knowledge !!

link|improve this question
feedback

2 Answers

up vote 2 down vote accepted
rsync -a -f"+ */" -f"+ *.[hc]" -f"- *" testdir newtestdir
link|improve this answer
feedback

rsync with use of --include can do this.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.