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

2007-12-25 3:41:00

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

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

Anyone have any ideas?

Thanks,
Colin.
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.

MSXI

Comments

Got something to say?

You must be logged in to post a comment.