Skip to content

Instantly share code, notes, and snippets.

@dreampuf

dreampuf/count.sh

Created Aug 1, 2014
Embed
What would you like to do?
Count a folder text file line count group by postfix
#!/bin/bash
find . -type f -print | xargs wc -l | while read count path; do echo ${path##*\.} $count; done | awk '{arr[$1] += $2} END {for (key in arr) printf("%s\t%s\n", key, arr[key])}' | sort
@dreampuf

This comment has been minimized.

Copy link
Owner Author

@dreampuf dreampuf commented Aug 1, 2014

result

nc      366
npmignore       5
pack    261147
patch   11660
pbxproj 710
pch     22
pdf     2079
pem     27
plist   229
png     9049
prefs   25
project 147
properties      123
proto   21
ps1     99
pub     1
py      17600
rdf     105
readme  1
sample  497
sh      1329
storyboard      509
svg     1634
thrift  270
total   1726994
ttf     1512
txt     118
woff    260
xcworkspacedata 7
xml     7689
xpi     6
xul     9
yaml    191
yml     587
zip     3295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment