SUMMARY: creating subdirectories with the cp command - is it possible?

From: Colin Haffenden <>
Date: Tue Jul 13 2004 - 10:32:03 EDT
Thanks to the mega quick responses... to many to list..

Basically cp cannot do it. Most responses said use mkdir -p which was
my fear of adding an extra line into an already time consuming script.

Others suggest tar or cpio which I will test the timings on.

Also rsync was suggested but I don't think that will help as I'm
copying the data locally.

Again thanks to all that responded

Original question....

Hi All,

I have had a look on google and the archives but can't seem to find any
answers on this.

Does anybody know whether it is possible to create subdirectories with
the cp command?

I have been given the task of moving some data and update a database at
the same time.

I will presented with a file like...

/original_dir/text.txt	/new_dir/non-existent_subdir1/nonexistent_subdir1/newtext.txt

I have added a few checks, cp and db update, but cp does not create the
new sub dirs.

I am reluctant to create all the new dirs within the same script as
there are about 3 million records and it's going to take forever to

I've checked the man page and couldn't see any options that would

Anyone have any ideas?

This Message has been Checked at MSXI for all known Viruses.
You open this at your own risk. Please make sure all replies are 
also virus free.
Also we do not accept or send Attachments of the type .exe, .vbs,
scr, or .bat due to the virus risk they can contain. These types of
attachments will be stripped from the message.

sunmanagers mailing list
Received on Tue Jul 13 10:32:34 2004

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:35 EST