Sorting files in a directory

Hi guys,

Probably an easy one, but how do you sort a directory so that the files come first, then subdirectories?

ie ./dir1 contains

file 1
subdir 1
file 2

i need it to become

file 1
file 2
subdir 1

as i'm using it in a script to pass each one through a for loop, and would like all the files done before going into the subdir.

Many thanks in advance

Oliver

Try this:

ls -l | sort -rd | awk '{print $9}'

Thanks, works a treat.

Oliver