Extracting from archive | compressing to new archive


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting from archive | compressing to new archive
# 1  
Old 12-20-2009
Question Extracting from archive | compressing to new archive

Hi there,

I have one huge archive (it's a system image).
I need sometime to create smaller archives with only one or two file from my big archive.
So I'm looking for a command that extracts files from an archive and pipe them to another one.
I tried the following :
Code:
tar -xzOf oldarchive.tgz ./file1 ./file2 | tar -czf newarchive.tgz

But it doesn't seem to work: it says:
Code:
tar: Cowardly refusing to create an empty archive

Can anybody explain me why?
Does anybody have a better idea?

Thanks for your help.
Santiago
# 2  
Old 12-20-2009
i couldnt understand why you used '0' in the code in '-xz0f'. I think it would work even if u dont use it in the first place. Try that out.
# 3  
Old 12-20-2009
Hey bdiwakarteja,
And thx for your interest.
-O means output to stdout instead of a file.
I thought it was necessary to redirect to another archive.
I can't try without it right now but I will do it asap.
Thx for your help
Santiago
# 4  
Old 12-20-2009
The problem is that tar can't archive files from stdin, only when they're given as arguments on the command line. I'm afraid you won't get around extracting the 2 files, and then tar'ing them again.
# 5  
Old 12-20-2009
Thanks pludi for your help.
This is a bit anoying because I'm not the administrator of the machine.
But the big archive contains files owned by root that are meant to be used for computers that I administrate.
So if I extract them to the filesystem before tar'ing them again, they will be owned by me and not root anymore.
Does anybody thinks of a way to get around the problem?
Thanks for your help
# 6  
Old 12-20-2009
Well, with -O you'd have lost the permissions anyways, as those can only be bound to a file, not to a stream. So IMO your best chance would be to extract the 2 files, move them to a machine you administer, and then create a new archive from them after you've corrected the permissions.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

2. UNIX for Dummies Questions & Answers

Cpio archive help

Hi I'm new to the forum and looking for some help with cpio archive creation. I have a bunch of directories that I need to make into a cpio archive. The problem I'm having is that when I input the commands I get the cpio archive but it creates a duplicate of the archive inside the archive... (4 Replies)
Discussion started by: reeves1985
4 Replies

3. UNIX for Advanced & Expert Users

Self extracting archive for Linux and windows

Is there a way to create a self extracting archive that works in both linux and windows? And if so how? Everything I have read on google only works in either Linux or Windows but not both. (6 Replies)
Discussion started by: cokedude
6 Replies

4. Homework & Coursework Questions

Creating and extracting archive file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hi there, I wish to create a single .tar file of the current directory but have literally no idea on where to... (8 Replies)
Discussion started by: Banned
8 Replies

5. Shell Programming and Scripting

Archive Files

I have 15-20 files in a unix folder on daily basis, so i need to archive those 20 files as dated today and place that archived files in a new folder and has to remove those 20 files from that folder. so that i place 20 new files that comes for tomorrow. i need write a unix script to do this. ... (1 Reply)
Discussion started by: gaddamshashank
1 Replies

6. Shell Programming and Scripting

Read specific file from a zip archive without extracting

Hi All, I would like to extract specific file from a zip archive. I have a zip archive "sample.zip". sample.zip contains few text files and images... text1.txt, text2.txt, pic.jpg etc... I need to read specific file "text2.txt" from "sample.zip" WITHOUT EXTRACTING the zip file. ... (4 Replies)
Discussion started by: sridharg
4 Replies

7. Shell Programming and Scripting

RCS archive in /etc

Well it is not a bad idea. I have worked for one place that did that. It wasn't my idea but I did not object. The reason it is done is to put critical files like nsswitch.conf, hosts, and so on under RCS control. Previous versions are then available to see how stuff changed over the years. ... (0 Replies)
Discussion started by: Perderabo
0 Replies

8. UNIX for Advanced & Expert Users

overhead in the archive

Hi everyone, I am currently trying to work out the size overhead in the library archive. The total size of all my objects file is about 100KB. However, when I package them into the archive (libXX.a), the size gets boosted up to 200KB. I want to know what exact is that 100KB overhead. I tried... (1 Reply)
Discussion started by: jasoncrab
1 Replies

9. UNIX for Dummies Questions & Answers

Extracting from a tar archive file

Can I extract files from an archive file (tar), where the filename includes the full directory path, to a different directory? For example the archive files may have a filename of /SrcFiles/XXX/filename.dat and I want to extract it to /SrcFiles/YYY/filename.dat. Since the archive file was... (1 Reply)
Discussion started by: nmalencia
1 Replies

10. UNIX for Dummies Questions & Answers

Q: tar archive help

hey how do you create a archive and add file to an existing archive. i keep getting an error: dir/#: No such file or directory currently using tar -cvfu name.tar files files searching from a word document each line having different file extention. Thanks in advance (1 Reply)
Discussion started by: nookie
1 Replies
Login or Register to Ask a Question