LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-18-2004, 09:46 AM   #1
BladeRunner
LQ Newbie
 
Registered: Sep 2003
Location: Kotor, Serbia & Montenegro
Distribution: Slackware 9.1
Posts: 5

Rep: Reputation: 0
How to copy tree without files in it?


I need to copy directory (with all it's subdirectories) from one place to another, but without files in that directory and all it's subdirectories. How to do that? (tar, cp, anything). Thank you!
 
Old 03-18-2004, 09:51 AM   #2
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,090

Rep: Reputation: 41
cp -R directoryname
 
Old 03-18-2004, 10:09 AM   #3
BladeRunner
LQ Newbie
 
Registered: Sep 2003
Location: Kotor, Serbia & Montenegro
Distribution: Slackware 9.1
Posts: 5

Original Poster
Rep: Reputation: 0
copy -R directory_name

copy directory recursively, WITH all files. I need to copy only tree structure (which means all directories and subdirectories), but without files. Thanx, anyway. Anyone else?

Root rulez
 
Old 03-18-2004, 10:29 AM   #4
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
Try this:
Code:
for foo in $(find /my/directory/ -type d);do mkdir .$foo;done
change /my/directory/ to the directory you want to copy

Last edited by Demonbane; 03-18-2004 at 10:31 AM.
 
Old 03-18-2004, 11:09 AM   #5
BladeRunner
LQ Newbie
 
Registered: Sep 2003
Location: Kotor, Serbia & Montenegro
Distribution: Slackware 9.1
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you! But, my problem is bigger than that. I also want to preserve all user and group permisions for that directories. This is great script, but it only creates files, without that. Thank you anyway. Bye!
 
Old 03-18-2004, 11:50 AM   #6
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
how about this:
Code:
for foo in $(find /my/directory/ -type d);do mkdir .$foo; chown --reference=$foo .$foo; chmod --reference=$foo .$foo;done
 
Old 03-22-2004, 01:01 PM   #7
jweller
LQ Newbie
 
Registered: Sep 2003
Distribution: fedora, ubuntu, uclinux
Posts: 23

Rep: Reputation: 15
Quote:
Originally posted by Demonbane
Try this:
Code:
for foo in $(find /my/directory/ -type d);do mkdir .$foo;done
change /my/directory/ to the directory you want to copy
quick Q. this doesn't seem to work for me when I type it on my command line. is there something I'm missing. it tells me "Illegal variable name" i changed foo to bar, but that gave me the same result.

I'm using tcsh. should I try this in another shell?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
locate and copy files - without directory tree rodda Linux - General 1 01-16-2005 02:10 AM
is reiserfsck --rebuild-tree safe for the HDD files? Necronomicom Slackware 1 06-21-2004 12:17 AM
the bible = the tree of the knowledge of good and evil () Jesus = the tree of life Michael111 General 2 04-14-2004 04:28 PM
how to copy and paste between files and within files Bheki Linux - General 1 02-05-2002 05:29 AM
How to copy a directory tree without copying the files in it? system Linux - General 2 01-15-2002 09:36 PM


All times are GMT -5. The time now is 03:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration