shellubuntuterminalcommand

How to find disk size of sub-folders of same name


Suppose directory structure on Ubuntu is /home/f1/a, /home/f2/a, /home/f3/a and /home/f4/a. Suppose my objective is to know the disk size of folders a within each f1,f2,f3,f4 (not the size of files inside these folders but the folders themselves); and to do it while I'm in /home.

Question What's the shell command I can run from /home to get the disk size of each folder a?

In my real world example I have 60 of these directories (i.e. ~/f1/a,~/f2/a,...,~/f60/a) so a command that doesn't spam too much other information is preferred.


Solution

  • this code works :

    for i in `seq 1 60`
    do
        du -ch ~/f$i/a | tail -n 1 | awk -F' ' {'print $1'}
    done