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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -