Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    bzip subdirectories

    Hi, can bzip compress files in subdirectories of the directory you tell it to? if so can you please give me the command switches or something like that? thanks

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Harrow, UK
    I don't think you can do this using bzip2 alone (though gzip has a recursion option). You can certainly do it with tar, using the -j option to invoke bzip2 as the compressor.
    tar -jf zipped_output.tbz directory
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  3. #3
    ok thank you. i'll just write a program to cycle through each subdirectory and call bzip on all the files in each

  4. $spacer_open
  5. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    Now hold on a sec. I think the solution to this depends on understanding what bzip does, and what you want.

    bzip is a utility that takes a single file and compresses it. I think you can do some weird things that allow it to handle multiple files, but this is not intelligent.

    Instead, if you want a single bzip archive to contain multiple files (or, say, a directory), you first create a tarball of the relevant files. A tarball is basically a box containing a bunch of different files. This is why you rarely see a straight .bz file: instead, you tend to see

    If you are wanting individual bzip archives of every file under a subtree, then iterating through each one is what you want (though I don't see why you would do this). If you want to compress an entire directory (including subdirectories), then make a tarball of the directory and then bzip that.

    Make sense?

  6. #5
    thanks, i know all about tarballs though. i use them all the time, although I prefer to gzip a tarball with ultra compression rather than bzip.

    I need to use bzip and compress each file individually for Counter-Strike Source fastdownload. that's just how it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts