Skip to content

Instantly share code, notes, and snippets.

@StephenMcGill-TRI
StephenMcGill-TRI / filetypeBySize.lua
Created July 26, 2016 15:35
Analyze a directory by file type, in terms of file size
#!/usr/bin/env luajit
-- Usage: ./sum.lua [DIRECTORY]
-- NOTE: The directory is not safely escaped
local dir = arg[1] or "."
-- Command gathered from: http://stackoverflow.com/questions/28376003
local f = io.popen('find '..dir..[[ -type f -print0 | xargs -0 du -k | grep "\.[a-zA-Z]*$" | rev | sed -e "s/\..*\t/\t/g" | rev]])
local ftype2ksz = {}