This is a discussion on converting .zip to .tar.gz or to .tar.bz2 within the Linux General forums, part of the Linux Forums category; I saw a post on ubuntuforums about converting a zip file to tar.gz and thought to myself that it ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I saw a post on ubuntuforums about converting a zip file to tar.gz and
thought to myself that it should easily be accomplished on the command line. After all, "zip -p" unzips to stdout and "tar -czvf -" compresses from stdin, so they need only be spliced together with a pipe. But I can't seem to figure it out. I keep getting back empty archives. (The .tar.gz file, not the original .zip.) I tried: unzip -p Qb45.zip | tar -cjvf - Qb45.tar.bz2 unzip -p Qb45.zip | tar -cjvf Qb45.tar.bz2 - unzip -p Qb45.zip | tar -cvf - | bzip2 > Qb45.tar.bz2 I obviously don't understand precisely what tar or gzip is doing with the piped data. What am I not doing? Thank you. -- The "mypacks.net" address from which this message was sent is legitimate and not spam-trapped. It is, however, disposable. |
|
|||
|
Michael DeBusk <chinos6398@mypacks.net> writes:
>I saw a post on ubuntuforums about converting a zip file to tar.gz and >thought to myself that it should easily be accomplished on the command >line. After all, "zip -p" unzips to stdout and "tar -czvf -" compresses >from stdin, so they need only be spliced together with a pipe. >But I can't seem to figure it out. I keep getting back empty archives. >(The .tar.gz file, not the original .zip.) >I tried: >unzip -p Qb45.zip | tar -cjvf - Qb45.tar.bz2 >unzip -p Qb45.zip | tar -cjvf Qb45.tar.bz2 - >unzip -p Qb45.zip | tar -cvf - | bzip2 > Qb45.tar.bz2 >I obviously don't understand precisely what tar or gzip is doing with >the piped data. What am I not doing? a) you are confused about the tar syntax. under -c option, the -f filename is the OUTPUT filename, not the input filename. Thus your first and third options are just wrong. b) unzip -p sends only the file data, not the filenames, etc to stdout. Ie, tar gets a stream of junk and it has no idea what to call that file. Just unzip into a directory mkdir /tmp/unzip cd /tmp/unzip unzip /location/of/the/zip/filename.zip tar -cjf /location/of/theQb45.tar.bz2 * |
|
|||
|
On Wed, 08 Aug 2007 05:49:49 -0000, Michael DeBusk
<chinos6398@mypacks.net> wrote: > > > I saw a post on ubuntuforums about converting a zip file to tar.gz and > thought to myself that it should easily be accomplished on the command > line. After all, "zip -p" unzips to stdout and "tar -czvf -" compresses > from stdin, so they need only be spliced together with a pipe. > > But I can't seem to figure it out. I keep getting back empty archives. > (The .tar.gz file, not the original .zip.) > > I tried: > > unzip -p Qb45.zip | tar -cjvf - Qb45.tar.bz2 > unzip -p Qb45.zip | tar -cjvf Qb45.tar.bz2 - > unzip -p Qb45.zip | tar -cvf - | bzip2 > Qb45.tar.bz2 > > I obviously don't understand precisely what tar or gzip is doing with > the piped data. What am I not doing? > > Thank you. > If the zip archive contains more than one file, you must extract it to a directory and then tar the directory. If the archive contains only one file, you can extract it to standard output and pipe it to gzip or bzip2 without tar. -- "Why should we subsidize intellectual curiosity?" -- Ronald Reagan |
|
|||
|
Bill Marcum wrote:
> .... snip ... > > If the zip archive contains more than one file, you must extract > it to a directory and then tar the directory. If the archive > contains only one file, you can extract it to standard output and > pipe it to gzip or bzip2 without tar. Which illustrates nicely why I consider zip to be more useful than tarring and gzipping. Zip keeps multiple files easily accessible, without going through a (possibly) long extraction and write, and consumption of untold disk space. The penalty is a very slight decrease in compression. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> -- Posted via a free Usenet account from http://www.teranews.com |
|
|||
|
On 2007-08-08, CBFalconer <cbfalconer@yahoo.com> wrote:
> Bill Marcum wrote: >> >> If the zip archive contains more than one file, you must extract >> it to a directory and then tar the directory. If the archive >> contains only one file, you can extract it to standard output and >> pipe it to gzip or bzip2 without tar. > > Which illustrates nicely why I consider zip to be more useful than > tarring and gzipping. Zip keeps multiple files easily accessible, > without going through a (possibly) long extraction and write, and > consumption of untold disk space. If you want to extract only certain files from a tar file, it's easy enough to do. You still have a possibly long read of the file, but you can certainly avoid the long write and disk use if you know what files you're looking for. And I don't see how zip gets around that issue, so I don't see how zip is any more or less useful than tar/gzip. --keith -- kkeller-usenet@wombat.san-francisco.ca.us (try just my userid to email me) AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt see X- headers for PGP signature information |
|
|||
|
On Wed, 08 Aug 2007 07:36:12 GMT, Unruh <unruh-spam@physics.ubc.ca> wrote:
> a) you are confused about the tar syntax. under -c option, the -f > filename is the OUTPUT filename, not the input filename. Thus your > first and third options are just wrong. No, I understood that the -f filename is the output filename. I got it wrong because I couldn't figure out how to put the filenames on the command line. I'm still pretty new at tar and gzip, and at the Linux command line in general. I'm figuring it out, though, I think. > b) unzip -p sends only the file data, not the filenames, etc to > stdout. Ie, tar gets a stream of junk and it has no idea what to call > that file. THAT is the problem, then. I was wrong in my original premise. Thanks. -- The "mypacks.net" address from which this message was sent is legitimate and not spam-trapped. It is, however, disposable. |
|
|||
|
On Wed, 08 Aug 2007 13:03:34 GMT, Bill Marcum <marcumbill@bellsouth.net> wrote:
> If the zip archive contains more than one file, you must extract it > to a directory and then tar the directory. If the archive contains > only one file, you can extract it to standard output and pipe it to > gzip or bzip2 without tar. And one would have to know which was the case before starting. :( -- The "mypacks.net" address from which this message was sent is legitimate and not spam-trapped. It is, however, disposable. |
|
|||
|
On Wed, 08 Aug 2007 10:35:47 -0400, CBFalconer <cbfalconer@yahoo.com> wrote:
> Which illustrates nicely why I consider zip to be more useful than > tarring and gzipping. Zip keeps multiple files easily accessible, > without going through a (possibly) long extraction and write, and > consumption of untold disk space. The penalty is a very slight > decrease in compression. I've been avoiding making that judgement because I've been concerned that I prefer zip simply because I'm so much more familiar with it. -- The "mypacks.net" address from which this message was sent is legitimate and not spam-trapped. It is, however, disposable. |
|
|||
|
Michael DeBusk <chinos6398@mypacks.net> writes:
>On Wed, 08 Aug 2007 07:36:12 GMT, Unruh <unruh-spam@physics.ubc.ca> wrote: >> a) you are confused about the tar syntax. under -c option, the -f >> filename is the OUTPUT filename, not the input filename. Thus your >> first and third options are just wrong. >No, I understood that the -f filename is the output filename. I got it >wrong because I couldn't figure out how to put the filenames on the The filename has to occur IMMEDIATELY after the f. >command line. I'm still pretty new at tar and gzip, and at the Linux >command line in general. I'm figuring it out, though, I think. >> b) unzip -p sends only the file data, not the filenames, etc to >> stdout. Ie, tar gets a stream of junk and it has no idea what to call >> that file. >THAT is the problem, then. I was wrong in my original premise. Thanks. |
|
|||
|
On Aug 8, 1:37 pm, Michael DeBusk <chinos6...@mypacks.net> wrote:
> On Wed, 08 Aug 2007 07:36:12 GMT, Unruh <unruh-s...@physics.ubc.ca> wrote: > > a) you are confused about the tar syntax. under -c option, the -f > > filename is the OUTPUT filename, not the input filename. Thus your > > first and third options are just wrong. > > No, I understood that the -f filename is the output filename. I got it > wrong because I couldn't figure out how to put the filenames on the > command line. I'm still pretty new at tar and gzip, and at the Linux > command line in general. I'm figuring it out, though, I think. > > > b) unzip -p sends only the file data, not the filenames, etc to > > stdout. Ie, tar gets a stream of junk and it has no idea what to call > > that file. > > THAT is the problem, then. I was wrong in my original premise. Thanks. > > -- > The "mypacks.net" address from which this message was sent is > legitimate and not spam-trapped. It is, however, disposable. Here is a situation where the man and/or info pages beat the tar (hehehe) out of the usage strings (--help option for some progs). Recommended reading for all unfamiliar w/ the Linux commandline, myself included ( I can get around all right, but I am a far cry from a guru). HTH, Tarkin |