Is there a way to see any tar progress per file?
I have a couple of big files that I would like to compress. I can do this with for example
tar cvfj big-files.tar.bz2 folder-with-big-files
The problem is that I can't see any progress, so I don't have a clue how long it will take or anything like that. Using v
I can at least see when each file is completed, but when the files are few and large this isn't the most helpful.
Is there a way I can get tar to show more detailed progress? Like a percentage done or a progress bar or estimated time left or something. Either for each single file or all of them or both.
I prefer oneliners like this:
tar cf - /folder-with-big-files -P | pv -s $(du -sb /folder-with-big-files | awk '{print $1}') | gzip > big-files.tar.gz
It will have output like this:
4.69GB 0:04:50 [16.3MB/s] [==========================> ] 78% ETA 0:01:21
For OSX (from Kenji's answer)
tar cf - /folder-with-big-files -P | pv -s $(($(du -sk /folder-with-big-files | awk '{print $1}') * 1024)) | gzip > big-files.tar.gz
Explanation:
-
tar
tarball tool -
cf
create file -
-
use stdout instead of a file (to be able to pipe the output to the next command) -
/folder-with-big-files
The input folder to zip -
-P
use absolute paths (not necessary, see comments)
pipe to
-
pv
progress monitor tool -
-s
use the following size as the total data size to transfer (for % calculation)-
$(...)
evaluate the expression -
du -sb /folder-with-big-files
disk usage summarize in one line with bytes. Returns eg8367213097 folder-with-big-files
- pipe (|) to
awk '{print $1}'
which returns only the first part of thedu
output (the bytes, removing the foldername)
-
pipe to
-
gzip
gzip compression tool -
big-files.tar.gz
output file name
You can use pv to achieve this. To report the progress correctly, pv
needs to know how much bytes you are throwing at it. So, the first step is to calculate the size (in kbyte). You can also completely drop the progress bar and just let pv
tell you how much bytes it has seen; it would report a 'done that much and that fast'.
% SIZE=`du -sk folder-with-big-files | cut -f 1`
And then:
% tar cvf - folder-with-big-files | pv -p -s ${SIZE}k | \
bzip2 -c > big-files.tar.bz2