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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -