0

So I'm trying to zip up a large number of files, but I want to see the total size of the files before I start zipping.

Before executing the following command to archive the files:

7za a files.7z files_2014-11-03*

I need to make sure I'm not zipping up too many files at once.

I used this command to find what I needed:

find -type f -name 'files_2014-11-03*' | wc -l

Is there something else I can pipe this to to get my wanted results?

user3299633
  • 2,971
  • 3
  • 24
  • 38
  • 1
    possible duplicate of [Calculate size of files in shell](http://stackoverflow.com/questions/599027/calculate-size-of-files-in-shell) – Victor Wong Nov 28 '14 at 02:26

2 Answers2

2
du -hc files_2014-11-03* | tail -1

I would use -c instead of -s

-c, --total           produce a grand total
Victor Wong
  • 2,486
  • 23
  • 32
1
du -bhs

More info

-b, --bytes
       equivalent to `--apparent-size --block-size=1'

-h, --human-readable
       print sizes in human readable format (e.g., 1K 234M 2G)

-s, --summarize
       display only a total for each argument

explainshell.com

Zombo
  • 1
  • 62
  • 391
  • 407