Skip to content

Instantly share code, notes, and snippets.

@bpedro
Created September 23, 2010 09:29
Show Gist options
  • Save bpedro/593391 to your computer and use it in GitHub Desktop.
Save bpedro/593391 to your computer and use it in GitHub Desktop.
#! /bin/sh
if test "$2" = ""; then
echo "usage: $0 basedir depth"
exit 1
fi
if test "$2" = "0"; then
exit 0
fi
hash_chars="0 1 2 3 4 5 6 7 8 9 a b c d e f"
hash_chars="$hash_chars g h i j k l m n o p q r s t u v"
if test "$2" -a "$2" -ge "5"; then
if test "$2" -eq "6"; then
hash_chars="$hash_chars w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - ,"
fi
fi
for i in $hash_chars; do
newpath="$1/$i"
mkdir $newpath || exit 1
sh $0 $newpath `expr $2 - 1` $2
done
@bpedro
Copy link
Author

bpedro commented Sep 23, 2010

Here's a quicker alternative that creates a 3 level tree:
mkdir -p {{a..z},{0..9}}/{{a..z},{0..9}}/{{a..z},{0..9}}

(thanks to http://twitter.com/bbarao)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment