0

I was trying to compress a folder into .tar format.

The folder size is around 76 MB.

Suppose I want to compress the folder myfolder to my-compressed-folder (in tar format)

I tried 2 approaches:

1) In the terminal, I executed:

tar -cjvf my-compressed-folder myfolder

The size of .tar by this method is 23 MB

2) On using the in-built Compress after right clicking on myfolder & choosing the .tar.xz, the size of .tar is around 17 MB.

I have 2 doubts:

1) How is there so much size difference in the 2 compressed files in same (.tar) format?

2) Is there any Linux command by which I can create compressed .tar files with the compression ratio same as the in-built Compress feature of Ubuntu?

My system details are as follows:

Ubuntu Desktop
Version 18.04.4 LTS (64-bit)
5
  • Doesn't the -j option of tar produce a bzip2 compressed file? if you want an apples to apples comparison to the xz file, you should use -J I think? May 11, 2020 at 17:40
  • @K7AAY I have added the Ubuntu system details
    – dashthird
    May 11, 2020 at 17:56
  • @steeldriver would try that now & update you shortly
    – dashthird
    May 11, 2020 at 17:57
  • @steeldriver Thanks! tar -cJvf worked :) How may I mark your comment as the answer?
    – dashthird
    May 11, 2020 at 18:02
  • I have added a brief answer below May 11, 2020 at 18:06

1 Answer 1

0

From man tar:

   -j, --bzip2
          Filter the archive through bzip2(1).

   -J, --xz
          Filter the archive through xz(1).

so your command tar -cjvf my-compressed-folder myfolder created a bzip2-compressed archive rather than an xz-compressed archive.

For an apples-to-apples comparison with the tar.xz file that you created from the file manager, you should use tar -cJvf my-compressed-folder myfolder.

1
  • Thanks once again! I thought they both (j and J) would work same like other options in many other Linux commands, but I was wrong
    – dashthird
    May 11, 2020 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.