why does tar sometimes include directory information?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers why does tar sometimes include directory information?
# 1  
Old 07-20-2008
Question why does tar sometimes include directory information?

hi,

say I have

dirA/file1
dirB/file2


and I tar them up, and then do

Code:
zcat Tar.tar | tar tvf -

Sometimes I will see:

dirA/
dirA/file1
dirB/
dirB/file2


yet other times I will see

dirA/file1
dirB/file2


i.e. no directory stuff

Why is this?

thanks
# 2  
Old 07-21-2008
tar has evolved over the years. The very first versions of tar did not copy directory information into the archive. The feeling was that if a directory was needed, just create it on the fly. But this lost directory ownership and permission info so it was fixed. A few current versions of tar has options to create an archive in this manner for compatibility with very old tar versions.

The way you phrase the question suggests that you thing omitting directories from a tar archive is normal or good. This is not the case.
# 3  
Old 07-22-2008
yes, but say I want to tar up

a/b/c/d/file1
x/y/z/file2


then if directory information is stored I will have

a/
a/b/
a/b/c/
a/b/c/d/
a/b/c/d/file1
x/
x/y/
x/y/z/
z/y/z/file2

Also, if I want to untar this and I already have these directories created on my system, then these new directory information will overwrite my directory information?

thanks
# 4  
Old 07-22-2008
Quote:
Originally Posted by JamesByars
Also, if I want to untar this and I already have these directories created on my system, then these new directory information will overwrite my directory information?
It should if you run it as root. Generally only root can give files away. Also if tar sets a directory to read-only, root can still put files in it. This is what tar usable to backup and restore files.
# 5  
Old 07-23-2008
thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Making Tar of directory and tar file is going to be placed

Quick question, is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?) sample: /opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz will the tar file backup.tgz also include backup.tgz ? i tried... (5 Replies)
Discussion started by: filosophizer
5 Replies

2. Shell Programming and Scripting

Find Command Include Sub Directory

This script writes the output files to FILES but I don't want to exclude all directories from ABC_CHQ and LYS_ADV, I want to include one sub directory name process which is under ABC_CHQ and LYS_ADV in the search. Right now its excluding everything from prune directories such as ABC_CHQ, LYS_ADV... (10 Replies)
Discussion started by: John William
10 Replies

3. Shell Programming and Scripting

Include information in certain columns using grep and awk

HI all, I have data in a file that looks like this: 1 HOW _ NNP NNP _ 3 nn _ _ 2 DRUGS _ NNP NNP _ 3 nn _ _ 3 ACT _ NNP NNP _ 0 null _ _ 4 : _ ... (3 Replies)
Discussion started by: owwow14
3 Replies

4. Shell Programming and Scripting

Include information and change column order while maintaing white spaces

I need to change the order of the columns of data that looks like this: The original data is in 6 tab-separated columns. FACTSHEET factsheet NN 1 5 DEP WHAT what WP 2 3 SBJ IS be VBZ 3 1 NMOD AIDS AIDS NP ... (1 Reply)
Discussion started by: owwow14
1 Replies

5. Shell Programming and Scripting

Include libexec directory for script when run

Hi everyone! This is my first post, so bear with me. I have this script, vpm, which make use of the libexec directory for commands intended to be run by the bin/vpm binary. I want to add the libexec directory to $PATH when running the vpm binary. I don't want the script itself to try figure... (2 Replies)
Discussion started by: KevinSjoberg
2 Replies

6. HP-UX

How do I include header files outside of my current directory

I am trying to compile a file called PPFormatageMUT.c in which I have included header file which are at some other location but the point is that while compiling the file, it is throwing error saying that error : no such file or directory source code location:... (1 Reply)
Discussion started by: ezee
1 Replies

7. UNIX for Advanced & Expert Users

How to rsync or tar directory trees, with hidden directory, but without files?

I want to backup all the directory tress, including hidden directories, without copying any files. find . -type d gives the perfect list. When I tried tar, it won't work for me because it tars all the files. find . -type d | xargs tar -cvf a.tar So i tried rsync. On my own test box, the... (4 Replies)
Discussion started by: fld2007
4 Replies

8. UNIX for Dummies Questions & Answers

tar include list

Hi, I am tarring a file as below. First,TMP_LOG_TAR.out is file which contain file path to include the file when i do tar. Second the, i am doing gzip the tarred file. Third, Sending a mail with gz file as attachment. But it fails to open the gz file in the mail tar -cf... (5 Replies)
Discussion started by: vino_hymi
5 Replies

9. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

10. Shell Programming and Scripting

include all files under a directory

I want to include all the subnet files under /etc/dhcpd/ to /etc/dhcpd.conf so here is my content of dhcpd.conf ... include "/etc/dhcpd/*"; however, the check-syntax reports syntax error, as they do not recognize the wildcard *, and display that " file /etc/dhcpd/* could not be found. ... (4 Replies)
Discussion started by: fredao
4 Replies
Login or Register to Ask a Question