1

Wanted to check for understanding; while revisiting the topic of using dd over netcat I experimented with compressing the data with bzip2. In the man page, there's -c (compress or decompress to standard output) and there's -z (complement to -d: forces compression, regardless of the invocation name)

Is -c simply a way to force the output to standard output, and using bzip2 at invocation implying you want to compress data if you don't use -d?

2 Answers 2

1

From the man page:

-d --decompress

Force decompression. bzip2, bunzip2 and bzcat are really the same program, and the decision about what actions to take is done on the basis of which name is used. This flag overrides that mechanism, and forces bzip2 to decompress

As this says bzip2, bunzip2 and bzcat are really the same binaries (oddly hardlinked binaries rather than symlinks to a single bzip2 binary on my system). When the program is run it will check the name it was executed under and act appropriately. bzip2 will compress by default, but -d will make it decompress. bunzip2 will decompress by default but -z will make it compress. bzcat will decompress to stdout by default while the other invocations require the -c option to output to stdout rather than a file.

Is -c simply a way to force the output to standard output, and using bzip2 at invocation implying you want to compress data if you don't use -d?

So to answer simply - yes.

0

This is actually explained in the manual:

   -d --decompress
          Force  decompression.   bzip2,  bunzip2 and bzcat are really the
          same program, and the decision about what  actions  to  take  is
          done  on  the  basis of which name is used.  This flag overrides
          that mechanism, and forces bzip2 to decompress.

So, when you call bunzip2 you are actually calling bzip2, the idea of the -c and -d flags is to allow you to force [de]compression no matter what name the program was called by.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .