Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Compress a entire directory

by kepler (Scribe)
on Jul 10, 2014 at 20:55 UTC ( [id://1093122]=perlquestion: print w/replies, xml ) Need Help??

kepler has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Does anyone has a clue how to compress in zip or tar format several files in the SAME compressed file? Kind regards, Kepler

Replies are listed 'Best First'.
Re: Compress a entire directory
by roboticus (Chancellor) on Jul 10, 2014 at 21:00 UTC

    kepler:

    You can do it with Archive::ZIP. Just traverse your directory tree and add the files to the ZIP file.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Compress a entire directory
by Laurent_R (Canon) on Jul 10, 2014 at 21:45 UTC
    Just a side note: tar is not really a compression utility and is not aimed at compressing data. The tar utility is for building an archive of several files (i.e. storing several files into a single file, with some way of extracting them afterwards), originally on a tape, today into a single file.. Now, having said that, there are often some options of tar that implicitly call the zip, gzip or compress utilities after having built the archive to reduce the size of the archive.

    I am also not sure to understand whether you want to do it in Perl or not.

Re: Compress a entire directory
by thomas895 (Deacon) on Jul 11, 2014 at 00:51 UTC
Re: Compress a entire directory
by perlfan (Vicar) on Jul 11, 2014 at 14:53 UTC
    Is this a Perl question or general *nix?

    Using just *nix commandline utilities, some ways to do this are:

    tar czvf ./directory-to-compress ./directory-to-compress.tgz # or equivalently tar cvf - ./directory-to-compress | gzip -c > ./directory-to-compres +s.tar.gz
    Suitable replacements for gzip included bzip2 and pigz.

    If you want to get crazy, you can use shar + gzip.

    shar ./directory-to-compress | gzip -c > directory-to-compress.shar.gz
Re: Compress a entire directory
by DrHyde (Prior) on Jul 11, 2014 at 10:07 UTC

    That you couldn't even be arsed to look at the manpages for tar(1), zip(1), Archive::Tar and Archive::Zip indicates to me that you don't actually care enough for me to bother helping you. You wouldn't even have to read very far down those pages, because the information you need is in the synopses for all four tools.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1093122]
Approved by hominid
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-04-19 08:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found