tags:

views:

201

answers:

5

Collectively check space of files in linux...

I have nearly more than 100 of files ...to check the size collectively...


Edit: What I need is: I have a folder containing 1000 files and I need something so that I can calculate the total sum [of what?] of 100 files only which I need...not all 1000 files.....

+4  A: 

This command will give you the size in kilobytes of all the individual files/directories in the current directory:

du -ks *

This command will give you the combined total size of the current directory:

du -ks .

If you need to recurse and get more detailed info, the find command might help.

Andy White
A: 

I'm no linux guru, but there should be some switch of the ls command that shows size.

If that fails, look into using du.

Charlie Somerville
A: 

This is a bit vague ... Assuming all you want is to get the total size of a bunch of files, there's any number of solutions.

If the files are all in the same directory, one very easy way is to just use

ls -lh | head -1

This prints a single line showing the "total" number, with a friendly "human-readable" (that's the -h option to ls) unit even.

Note that this does not work with wildcards, since then ls suppresses its "total"-line.

unwind
+1  A: 

If you want the total size of all files in the current directory (In "human readable format")

du -sh
John T
A: 

Using gdu:


aaa:vim70> gdu 
5028    ./doc
4420    ./syntax
.
.
.
176     ./compiler
16      ./macros/hanoi
16      ./macros/life
48      ./macros/maze
20      ./macros/urm
200     ./macros
252     ./keymap
18000   .

You can use --max-depth to limit the depth of the search:


aaa:vim70> gdu --max-depth=1
5028    ./doc
136     ./print
76      ./colors
4420    ./syntax
420     ./indent
628     ./ftplugin
1260    ./autoload
64      ./plugin
800     ./tutor
3348    ./spell
176     ./compiler
200     ./macros
112     ./tools
844     ./lang
252     ./keymap
18000   .

Notice that the subdirectories of macros don't appear.

or even:

aaa:vim70> gdu --max-depth=0
18000   .

The default unit is kilobytes. You can use -h to get it in human readable form:


aaa:vim70> gdu --max-depth=1 -h
5.0M    ./doc
136k    ./print
76k     ./colors
4.4M    ./syntax
420k    ./indent
628k    ./ftplugin
1.3M    ./autoload
64k     ./plugin
800k    ./tutor
3.3M    ./spell
176k    ./compiler
200k    ./macros
112k    ./tools
844k    ./lang
252k    ./keymap
18M     .

Nathan Fellman
plz come to linux and simple commands
vivek
i am not able to understand
vivek
@vivek: these two comments are not very sensible - though the first is better than the second.
Jonathan Leffler