TonyW
TonyW

Reputation: 18885

Convert file format from .bz2 to gz on Mac

I have lots of bunzip2 compressed files that I would like to convert to .gz. I tried the following using a pipe, but it does not work. I guess the reason is gzip does not know what files to zip.

bunzip2 test.txt.bz2 | gzip

any way to use a pipe for connecting bunzip2 and gzip ?

Upvotes: 1

Views: 1489

Answers (1)

tallungulate
tallungulate

Reputation: 181

When running gzip with no parameters, it expects its output to be piped into a file:

bzcat test.txt.bz2 | gzip -c - >test.txt.gz

For completeness, I have included the following (although they are both optional when input is from standard input and output is redirected or sent to another pipe):

  • -c option (Write output on standard output)
  • a file name of - (If no files are specified, or if a file name is "-", the standard input is compressed to the standard output.)

Upvotes: 4

Related Questions