Tar pre-run to estimate expected file size or number

Problem: I have a background process that at some point it collects and creates a large tar file. This tar retrieves multiple directories and excludes files. the process can take up to several minutes, and I want to inform in my interface process (GUI) about the progress of the calibration process (This is a big problem for the user who clicks the download button and it seems that nothing is happening ...).

I know I can use -v -R in tar files and count files and size, but I'm looking for some kind of preliminary tar / dry run mode to help me evaluate either the expected number of files or the expected tar size.

the command I use is: tar -jcf 'FILE.tgz' 'exclude_files' 'include_dirs_and_files'

10x for anyone who wants to help.

+5
source share
2

wc .

(verbose):

[git@server]$ tar czvf - ./test-dir | wc -c
./test-dir/
./test-dir/test.pdf
./test-dir/test2.pdf
2734080

:

[git@server]$ tar czf - ./test-dir | wc -c
2734080
+11

DIRS=("./test-dir" "./other-dir-to-test")
find ${DIRS[@]} -type f | wc -l

. (-type f) . DIRS - bash,

, du

DIRS=("./test-dir" "./other-dir-to-test")
du -c -d 0 ${DIRS[@]} | tail -1 | awk -F ' ' '{print $1}'

du, ( -c), ( 4378921 total) awk

+1

All Articles