Checking space in Linux

Collectively check file space in Linux ...

I have almost 100+ files ... to check the size collectively ...


Edit: I need: I have a folder containing 1000 files and I need something so that I can calculate the total [from what?] Of the 100 files I need ... not all 1000 files .... ...

0


a source to share


5 answers


It's a bit vague ... Assuming all you need is to get the total size of the pile of files, there will be any number of solutions.

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

ls -lh | head -1

      



This prints one line showing the "total" number, with a friendly "human-readable" (which is an option -h

for ls) even.

Note that this does not work with wildcards, since then ls suppresses its "final" string.

0


a source


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

du -ks *

      

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



du -ks .

      

If you need to rewrite and get more details, the find command can help.

+4


a source


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

du -sh

      

+1


a source


I'm not a linux guru, but there must be some command switch ls

that shows the size.

If that fails, investigate the usage du

.

0


a source


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 to limit your search depth: --max-depth


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   .

      

Note that subdirectories are macros

not displayed.

or even:

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

      

The default unit is kilobyte. 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     .


      

0


a source







All Articles