1829585 Members
1780 Online
109992 Solutions
New Discussion

Re: cp command question

 
SOLVED
Go to solution
Hunki
Super Advisor

cp command question


I need to copy a file from a path lets say :

/a/b/c/file-name

to

/d

such that the file is copied as /d/a/b/c/filename.( and I dont have to do a mkdir to create the directories in /d )
4 REPLIES 4
Torsten.
Acclaimed Contributor

Re: cp command question

If the files have different owners and permissions, create a tar and restore it to the new location.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Sandman!
Honored Contributor
Solution

Re: cp command question

Use pax(1) to get that effect i.e.

# pax -rw /a/b/c/file_name /d/

~cheers
James R. Ferguson
Acclaimed Contributor

Re: cp command question

Hi:

You can short-circut the creation of a multi-level directory with:

# mkdir -p /dir1/dir2/dir3/dir4

See the 'mkdir' manpages.

Regards!

...JRF...
Hunki
Super Advisor

Re: cp command question

Thanks you all and specially to Sandman !