Link to home
Start Free TrialLog in
Avatar of farzanj
farzanjFlag for Canada

asked on

linux tar

I have a huge tar 'tgz' file -- it is compressed using gzip tar option.  I want to delete a few files like a/b/c/d* from it.

As I try do delete
tar -f mytar.tgz --delete 'a/b/c/d*'
It gives the following error message.
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
tar: Archive contains `\033L\254\343\360\303\302J\211d\205k' where numeric off_t value expected
tar: Skipping to next header
tar: a/b/c/d*: Not found in archive
tar: Error exit delayed from previous errors


I tried z option also but  to no avail.  I certainly don't want to extract the whole tar to remove those files.
Avatar of Ferrosti
Ferrosti
Flag of Germany image

This is not a straight tar archive, it´s a '.tar.gz' as its name and error message shows. You´ll need to give it a decompress option. I am not sure whether deletion works on compressed archives. Never tried it.
Avatar of farzanj

ASKER

Well append and delete works on tar and are very vital operations if you are dealing with huge tars.
Delete worked for me after I did gunzip on my tar.  But since it was huge, it took extra time doing and the recompressing it.  I simply wonder if there is a way to eliminate that extra drill
you could try specify:
tar -zf

this tells tar that the archive is compressed.

best
Well, i tried it and it gave me:

tar: Cannot update compressed archives
Try `tar --help' or `tar --usage' for more information.

so, I guess no luck, seems as you have to unzip it before update/delete operations can be done.

best
Ray
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is an example of creating an archive and extracting a single file from it.
If you use tar -xvf path
that will extract your file

[jhelfman@eggman ~]$ tar -cvf test.tgz tmp/
a tmp
a tmp/expert.html
a tmp/error
[jhelfman@eggman ~]$ cd ugh/
[jhelfman@eggman ~/ugh]$ ls
[jhelfman@eggman ~/ugh]$ tar xvf ../test.tgz tmp/expert.html
x tmp/expert.html
[jhelfman@eggman ~/ugh]$ ls
tmp
[jhelfman@eggman ~/ugh]$ cd tmp/
[jhelfman@eggman ~/ugh/tmp]$ ls
expert.html

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of farzanj

ASKER

Ok.  Thanks all.
Avatar of farzanj

ASKER

The only question now is about Arnold's fancy redirection.  Is it going to take drive space equal to = tar + tar.gz?
It usually runs in RAM until it needs to swap :)
Ah, sorry, misunderstood your question!
Yes, you will need space for the old file as well as the new one you have created without needed files.