bash - Order filenames by number of appereances of given character? -


i want output list of file names in directory, list should ordered descending number of appeareances of given character in each file name. how can bash?

let want sort occurences of "a" in file names:

for in *; do; echo "`grep -o "a" <<< "$i" | wc -l` $i"; done | sort -r 

result

$ ls carla elaine guybrush herman largo leamon-head lechuck max meathook ozzie sam stan voodoo  $ in *; do; echo "`grep -o "a" <<< "$i" | wc -l` $i"; done | sort -r 2 leamon-head 2 carla 1 stan 1 sam 1 meathook 1 max 1 largo 1 herman 1 elaine 0 voodoo 0 ozzie 0 lechuck 0 guybrush 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -