Advertisement
sebbu

list number of files and total size by extension

Dec 6th, 2023
1,620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | Software | 0 0
  1. #!/bin/bash
  2. LC_ALL=C find . -name '?*.*' -type f -printf '%s.%f\0' |
  3. LC_ALL=C gawk -F . -v RS='\0' '
  4.     {
  5.         if(NF==2) $(NF+1)=" "; 
  6.         s[$NF] += $1;
  7.         n[$NF]++
  8.     }
  9.     END {
  10.         PROCINFO["sorted_in"] = "@val_num_asc"
  11.         for (e in s) printf "%15d %4d %s\n", s[e], n[e], e
  12.     }' |
  13. numfmt --to=iec-i --suffix=B
  14.  
Tags: BASH GNU
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement