LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-19-2003, 12:08 PM   #1
shelby
Member
 
Registered: Nov 2002
Location: Rio Rancho, NM
Distribution: RHEL, CentOS & Ubuntu
Posts: 90

Rep: Reputation: 15
Can I tar a directory structure....


Can I tar a directory structure? Is it posssible to tar a directory structure. I dont need the data inside the directories. These are NFS and Samba shares and just want to be able to recreate the mount points with min fuss. Thanks
 
Old 02-19-2003, 12:24 PM   #2
Ztyx
Member
 
Registered: Dec 2001
Location: Stockholm, Sweden
Distribution: Ubuntu, Kubuntu and Debian
Posts: 338

Rep: Reputation: 30
Yes.
 
Old 02-19-2003, 12:35 PM   #3
shelby
Member
 
Registered: Nov 2002
Location: Rio Rancho, NM
Distribution: RHEL, CentOS & Ubuntu
Posts: 90

Original Poster
Rep: Reputation: 15
Mine sharing the syntax with me? Thanks
 
Old 02-19-2003, 12:42 PM   #4
Ztyx
Member
 
Registered: Dec 2001
Location: Stockholm, Sweden
Distribution: Ubuntu, Kubuntu and Debian
Posts: 338

Rep: Reputation: 30
To create a tar file containing the directory structure:
tar -cl /path/to/directory > /path/to/my/newly/created/tar/file.tar

Quote:
Quote from "man tar":
-l, --one-file-system
stay in local file system when creating an archive
 
Old 02-19-2003, 12:49 PM   #5
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 58
Telling tar Which Files to Exclude or Include
 
Old 02-19-2003, 08:29 PM   #6
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
Quote:
Originally posted by shelby
Mine sharing the syntax with me? Thanks
Dark ninja secrets you seek...
 
Old 02-19-2003, 09:08 PM   #7
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
doesnt tar -cf do the same job
 
Old 02-19-2003, 09:14 PM   #8
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
The difference being this person doesn't want files in the directories. So, tarring up the directory would work, but isn't what they are looking for. They want structure, not files

Cool
 
Old 02-20-2003, 08:10 AM   #9
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well I don't think there is any specific switch for tar which will do this, at least I couldn't find any. Here is how I would do something like what you where looking for. It's just an example of the commands I used, you might want to make a script out of it if you want to do it more often.

Code:
$ mkdir /tmp/dirstruct
$ cd /tmp/dirstruct
$ find /usr/include -type d | sed -e 's#/usr/include/##' | xargs mkdir
$ tar czvf dirstruct.tar.gz *
$ mkdir /tmp/newdirstruct
$ cd /tmp/newdirstruct
$ tar xzvf ../dirstruct/dirstruct.tar.gz
The find command searches for only directories. The sed command then strips off the leading path. You have to make sure that in the sed command the trailing / is present otherwise it will try to make the directory structure in the root which isn't what you want. The xargs command passes the directories to the mkdir command so it can create each directory in the current directory.
Well hope that helps get you closer to the solution to your problem.
 
Old 02-20-2003, 09:17 AM   #10
shelby
Member
 
Registered: Nov 2002
Location: Rio Rancho, NM
Distribution: RHEL, CentOS & Ubuntu
Posts: 90

Original Poster
Rep: Reputation: 15
Thanks I will give it a shot.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory Structure fedix Linux - Newbie 3 10-14-2005 02:48 PM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 06:05 AM
directory structure alaios Linux From Scratch 4 04-20-2004 06:16 PM
understanding directory structure wincrk Linux - General 6 03-02-2003 07:11 AM
directory structure sluggo Linux - Newbie 1 01-20-2002 08:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:56 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration