Is there a way to see any tar progress per file?
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 toolcf
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 expressiondu -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 toolbig-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
better progress bar..
apt-get install pv dialog
(pv -n file.tgz | tar xzf - -C target_directory ) \
2>&1 | dialog --gauge "Extracting file..." 6 50