Ubuntu – Copy files and directories without files content

command line

Is there a way to copy directory structure with files but without their contents. I mean that I want exactly the same directories with files names but leaving them blank/empty. I have few example applications in some programming language and I want to rewrite them with my own style but keeping the way that they was organised in files.

I would be grateful for any help.

Best Answer

From man cp

--attributes-only don't copy the file data, just the attributes

So , if you want to copy all folders and files that are in somedirectory

do cp -R --attributes-only somedirectory destinationdirectory