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' -

java - Log4j2 configuration not found when running standalone application builded by shade plugin -

python - How do I create a list index that loops through integers in another list -