[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to cp dir and subdir but not the parentdirectory?



On Fri, Nov 18, 2005 at 04:23:57PM +0100, Realos wrote:
> I like to copy all contents of a directory "testdir",i.e. all its
> files and subdirectories, into another directory called "temp". 
> 
> The problem is that the directory "testdir" itself is also being created
> inside the "temp" directory. How can I copy _only_ contents of "testdir" without that parent directory, namely "testdir" being recreated inside "temp"?
> 
> Following is how it all looks like in my case:
> 
> user@labpc307:~$ ll
> drwxr-xr-x  3 user user     1024 2005-11-18 16:05 temp
> drwxr-xr-x  3 user user     1024 2005-11-18 16:04 testdir
> 
> user@labpc307:~$ ll testdir/
> drwxr-xr-x  2 user user 1024 2005-11-18 16:05 testdir_1
> -rw-r--r--  1 user user    0 2005-11-18 16:04 testfile_a
> -rw-r--r--  1 user user    0 2005-11-18 16:04 testfile_b
> -rw-r--r--  1 user user    0 2005-11-18 16:04 testfile_c
> -rw-r--r--  1 user user    0 2005-11-18 16:04 testfile_d
> 
> user@labpc307:~$ cp -drp testdir/ temp/
> user@labpc307:~$ ll temp/
> drwxr-xr-x  3 user user 1024 2005-11-18 16:04 testdir
> 
> I know I could copy all files with "cp * temp" and then all subdirectories one by one butI would prefer a single command to do that. Any chance?
> 
Hi,

cp -r testdir/* temp might do the trick

Pete

> Regards,
> 
> -- 
> Realos
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 



Reply to: