self-learning! my korn shell problem

i am a beginner i m learning shell by myself
i have problem writing a korn shell that takes an absolute pathname to directory and display all ordinary files in the directory ordered by their length.
i was thinking use grep ls sort and sed. maybe, i m wrong! can someone tell me?

This sounds like homework. We have a special forum for that.

However:

#!/bin/ksh
# parms $1 = absolute path to files
path="$1"
cd $path
ls |
while read fname
do
   if [ -f $fname  ] ; then # is this a regular file, not a dir or pipe, etc
      ls -l $fname 
   fi
done | sort -n -k 5

watch spaces arounnd brackets....

( find $path -type f | xargs -n101 ls -l ) | sort -n -k 5

This 101 is dedicated to dude DGnitPickett :slight_smile: