Measure disk space of certain file types in aggregate Measure disk space of certain file types in aggregate linux linux

Measure disk space of certain file types in aggregate


find folder1 folder2 -iname '*.txt' -print0 | du --files0-from - -c -s | tail -1


This will report disk space usage in bytes by extension:

find . -type f -printf "%f %s\n" |  awk '{      PARTSCOUNT=split( $1, FILEPARTS, "." );      EXTENSION=PARTSCOUNT == 1 ? "NULL" : FILEPARTS[PARTSCOUNT];      FILETYPE_MAP[EXTENSION]+=$2    }   END {     for( FILETYPE in FILETYPE_MAP ) {       print FILETYPE_MAP[FILETYPE], FILETYPE;      }   }' | sort -n

Output:

3250 png30334451 mov57725092729 m4a69460813270 3gp79456825676 mp3131208301755 mp4


Simple:

du -ch *.txt

If you just want the total space taken to show up, then:

du -ch *.txt | tail -1