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

how to cp dir and subdir but not the parentdirectory?



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?

Regards,

-- 
Realos



Reply to: