LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-09-2007, 05:09 AM   #1
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 651

Rep: Reputation: 34
need to careate archive od only the directory


I want to create an archive of directory structure. and I have tried to pipe the output of find command as fallows but it is not working

find ./123/ -type d | tar -cvf 123.tar

Can some one tell me how to do this. All I need is the empty directories
 
Old 03-09-2007, 05:31 AM   #2
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 449

Rep: Reputation: 34
Why can't you just do:

Code:
tar cvf 123.tar *
EDIT: I just re-read, and I think you were actually saying you just want to DIRECTORIES, not the file inside them...?
 
Old 03-09-2007, 05:45 AM   #3
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
A few remarks:
1. Don't pass a directory and all it's subdirectories to "tar". If you give it the (top-level) directory to archive, then it'll go through all files/subdirectories recursively.
So, in your case, you only need to do:
Code:
tar -cvf 123.tar 123/
2. If you only want empty directories (so bare directory tree), without any regular files, you first need to either remove all regular files (ie run "find 123 -type f -exec rm {} \;" ) or to create a copy of your directory structure (without copying the files). The latter can be done for instance by running:
Code:
find 123 -type d -exec mkdir /new/path/{} \;
tar -cvf 123.tar /new/path/123/
Check your results via a "tar -tvf 123.tar".
 
Old 03-09-2007, 05:53 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could create an identical directory structure in another directory and then tar that.

mkdir 123tardir
find 123/ -type d -exec mkdir ../123tardir/'{}' \;
cd 123tardir
tar cvf ../123.tar .
 
Old 03-12-2007, 12:46 AM   #5
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 651

Original Poster
Rep: Reputation: 34
Hi Guys Thank you for you'r help. What I wanted was to take a empty directory structure to a another machine and create it there (directories only). I was able to do this by using

Create the directory tree

1) find . -type d -depth -print |cpio -ovcB > dir-tree.cpio


Extract - Only Directory Tree

2) cpio -icvBdum < dir-tree.cpio

Best regards

Asanka
 
  


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
(un)tar a certain directory from an archive Suinatsa Linux - Software 2 06-20-2006 07:09 AM
how to copy-in cpio archive to temp directory jxi Slackware 2 03-08-2006 04:32 PM
tar - extracting a single directory from a large archive? lowpro2k3 Linux - General 1 07-24-2005 02:44 AM
divide a directory into multiple archive files with par ddaas Linux - General 1 02-26-2005 01:52 PM
Trying to archive a 4.6 GB directory kaplan71 Linux - General 2 04-27-2004 10:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration