Find the answer to your Linux question:
Results 1 to 5 of 5
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...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    33

    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
    Location
    Harrow, UK
    Posts
    1,220
    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.
    Code:
    tar -jf zipped_output.tbz directory
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Just Joined!
    Join Date
    Aug 2008
    Posts
    33
    ok thank you. i'll just write a program to cycle through each subdirectory and call bzip on all the files in each

  4. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    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 .tar.bz.

    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?

  5. #5
    Just Joined!
    Join Date
    Aug 2008
    Posts
    33
    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
  •