Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question may sound weird but I would like to know if there is a possibility to display the deflation percentage of the files processed in the tar command.

I use this command tar -cjvf "$BACKUP_PATH/Complete Backup $date.tar.bz2" $MINECRAFT_PATH to create a backup of a minecraft game server. And this is displaying all the files it is processing. This looks almost like the zip command. The difference here is that once the zip command is finished it displays how much the file got deflated. I wonder if this is possible with the tar command.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

It is not possible, because the files are first archived (tar) then the result is compressed as a whole (bz2 or gz). This is (edit: one of) the reasons why tar.bz2 or tar.gz are usually smaller than zip, specially when they contain a lot of small and similar files.

share|improve this answer
    
That's not the only reason. You can't compare the compression ratio between bzip2, gzip and zip directly because each of them uses a different compression algorithm. –  scai Aug 20 '13 at 14:26
1  
as far as I know gzip and zip algorithm are quite similar (based on DEFLATE) but you're right, I'll edit the answer –  bwt Aug 20 '13 at 14:37
    
almost all Zip archives use the same DEFLATE as gzip – you can even use gunzip with them; APPNOTE.TXT also allows using bzip2 (and a few other algorithms). –  grawity Aug 20 '13 at 14:44

If you first run tar and then either gzip or bzip2, then you can pass both of these the option -v to show the compression ratio, e.g. like this:

tar -cvf - foo/ | bzip2 -v > foo.tar.bz2
share|improve this answer

What for? You can tell to tar write to stdout number block is processed, or you can run command that get processed block number. this is base for percentage display. use option

tar ...something ... --checkpoint --checkpoint-action=ACTION

see man tar .

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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