Created
November 26, 2010 14:49
-
-
Save l0b0/716802 to your computer and use it in GitHub Desktop.
Count the number of files in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This works even with really weird filenames like $'--$`\! *@ \a\b\e\E\f\n\r\t\v\\\"\' ' | |
file_count() | |
{ | |
if [ ! -e "$1" ] | |
then | |
exit 1 | |
fi | |
local -i files=$(find "$(readlink -f -- "$1")" -type f -print0 | grep -cz -- -) | |
echo $files | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment