Skip to content

Instantly share code, notes, and snippets.

@xtman
Last active June 12, 2024 05:26
Show Gist options
  • Save xtman/328e6084216e918f89fa1fdec6ab859a to your computer and use it in GitHub Desktop.
Save xtman/328e6084216e918f89fa1fdec6ab859a to your computer and use it in GitHub Desktop.
#!/bin/sh
[ $# -ne 1 ] && echo "$(basename $0) <dir>" && exit 1
[ ! -d $1 ] && echo "$1 is not a directory." && exit 1
if [ $(uname) == "Darwin" ]; then
find "$1" -type f -print0 | xargs -0 stat -f '%z ' | paste -sd+ - | bc
else
find "$1" -type f -printf %s\\n | paste -sd+ | bc
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment