Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory volume

Status
Not open for further replies.

YO123

MIS
Jul 26, 2001
77
BE
I'm looking for a way to come up with a total sum of bytes taken (in K) for a number of files with the same extension in one directory

Tnx,

YO
 
Quick and dirty, from the directory in which the files reside:

du -k *.txt

(replace txt with your chosen extension).

This will give you a total for individual files, but should serve as a startpoint. Hope this helps.

 
This is not exactly what I'm looking for.

I have a bunch of file with the name XXXX, but they all have a different extension.

Now I want something that gives me the total sum of space that all the files toghether have.

Tnx
 
OK, but that's not what you said, now is it?;-)

Anyway:

du -k <filename>.*

will give you the individual sizes of files (in K, but be aware that any proportion of a K which a file takes up is regarded as a full K for this purpose) with the name <filename>.<any extension>

Hopefully this will give you a start. I'll post back with a better solution (if I can think of one) if I get the time today.
 
To get the total sum, use du -sk <filename>.*.

And even though you didn't ask for it, this is for those who may be wondering: if you want to know which files/directories are taking the most space, use du -sk * | sort -n. This will sort the list from smallest to largest.

 
bi, thanks for that, I'd forgotten about the -s option. Oh hum, it's been a long week!
 
hi,

I tried this, but the only list I get out of this is a complete list of all the files with all the different extensions, and in front the size of each file, but anywhere the total sum of all the files.

here an example of my output

du -sk local.*
51200 local.b1
4 local.b2
102400 local.d1
102400 local.d2
102400 local.d3
102400 local.d4
201296 local.d5
4 local.db

what I really want is now at the bottom or at the top a total stating: 662104 OR any other way to get this number will do.

tnx

YO
 
For anyone interested: I found the solution

Tnx for your help to get me started.

try : du -sk <filename>.* | awk '{print sum += $1}'|tail -1

YO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top