954,228 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

copy only sub directories

Hi,
Am trying to copy all the directories alone within a directory. I tried something like

ls -ltr | awk '$1 ~/^d/{print $8} ' | xargs cp -r dest_dir

the first part

ls -ltr | awk '$1 ~/^d/{print $8} '

gives O/P
Testing

But it keeps saying cp cannot access Testing.
Testing folder has rwx permissions for everyone.

voidyman
Newbie Poster
17 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

Try this instead:

find path-to-dir -maxdepth 1 -type d -exec cp -rfp {} path-to-backup-dir \;
rubberman
Posting Virtuoso
1,559 posts since Mar 2010
Reputation Points: 277
Solved Threads: 178
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: