Skip to content

Instantly share code, notes, and snippets.

@pavgup
Created May 4, 2015 13:18
Show Gist options
  • Save pavgup/60e960572bd4ba01df90 to your computer and use it in GitHub Desktop.
Save pavgup/60e960572bd4ba01df90 to your computer and use it in GitHub Desktop.
Before a magical image optimization pipeline kicks off (e.g., imagemin inside grunt/gulp) you'd probably want to know what the size of all your images are. Here's a quick one-liner that grabs a filetype for every file inside your current directory and then awks out the files that *nix is considering an image before finally handing off the file s…
#!/bin/sh
# Before a magical image optimization pipeline kicks off (e.g., imagemin inside
# grunt/gulp) you'd probably want to know what the size of all your images are.
# Here's a quick one-liner that grabs a filetype for every file inside your
# current directory and then awks out the files that *nix is considering an
# image before finally handing off the file size calculations to du.
find . -exec file {} \; | \
awk -F':' '{
if ($2 ~/[Ii]mage|EPS/)
print $1,"\n"
}' | \
xargs du -hc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment