I have a directory with a lot of header files (.h) and other .o and .c files and other files. There are many nested directories inside this directory. I want to copy only the header files to a separate directory, preserving the same structure in the new directory.
cp -rf oldDirectory newDirectorywill copy all files. I want to copy only the header files.
cp -rf oldDirectory newDirectory
(cd src && find . -name '*.h' -print | tar --create --files-from -) | (cd dst && tar xvfp -)
- cpio, , , , , mv'ing. ( !), . , dst src - , :
cp -rf oldDirectory/*.h newDirectory
- ( )
find oldDirectory -type f -name "*.h" -print0 | xargs -file cp file newDirectory
this one worked for me:
rsync -avm --include='*.h' -f 'hide,! */' . /destination_dir
from here