1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# bash script to find all extensions in the current tree
find . -type f -name '*.*' | awk -F. '{print $NF}' > /tmp/extensions.txt

# python script to count extensions
extensions = {}
f = open( '/tmp/extensions.txt' )
for extension in f.readlines():
    extension = extension.rstrip()
    if extension in extensions:
        extensions[extension] += 1
    else:
        extensions[extension] = 1
print 'extension,count'
for extension, count in extensions.items():
    print '%s,%s' % ( extension, count )
f.close()