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 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 !!

share|improve this question

2 Answers 2

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

rsync with use of --include can do this.

share|improve this answer

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.