folder="/usr/share/fonts/*" extension="ttf" i=0 for file in $folder #/usr/share/fonts/opentype/* do for picked in "$file"/* do if [[ $picked == *"$extension"* ]]; then array[$i]="$picked" ((i++)) fi done done sorted=(`printf "%s\n" "${array[@]}" | sort -ft/ -k6`) count=${#sorted[@]} #Array is 0 to count # output to Fonts.html echo "" > Fonts.html # creates new file or overwrites existing file echo "" >> Fonts.html # rest of the lines append to the Fonts.html file echo "" >> Fonts.html echo "" >> Fonts.html echo "

Font Listing

" >> Fonts.html echo "
" >> Fonts.html # echo "${FILE%%.*}" echo "" >> Fonts.html for ((i = 0 ; i < $count ; i++ )) do temp="${sorted[i]%%.*}" # remove extension t1="${temp##*/}" # remove path j=$((i+1)) echo "" >> Fonts.html done echo "
${j}. ${t1} ABCDEFGHIJKLMNOPQRSTUVWXYZ
" >> Fonts.html echo "" >> Fonts.html echo "" >> Fonts.html