#!/bin/bash # # # if [ -z "$1" ]; then echo -n "Enter a path: " read path chk=`ls $path 2>&1 | grep 'No such file' | wc -l` if [ "$chk" -eq 1 ]; then path=`pwd` fi else path="$1" fi echo $path cd $path max=0 for file in `ls -1d *`; do c=`echo $file | wc -c` let data[$c]=${data[$c]}+1 if [ "$max" -lt "$c" ]; then max=$c fi done for((i=1; i<=$max; i++)); do printf "%2d | " $i if [ -z "${data[$i]}" ]; then data[$i]=0 fi if [ ! "${data[$i]}" -eq 0 ]; then echo -n "tro" else echo " " fi for((j=0; j<${data[$i]}; j++)); do if [ ! "${data[$i]}" -eq 0 ]; then echo -n "lo" fi done if [ ! "${data[$i]}" -eq 0 ]; then echo "l" fi done