![](https://seccdn.libravatar.org/avatar/d1bfaab38ee40a13fb229311f9f5c079.jpg?s=120&d=mm&r=g)
Þann laugardagur 21 júlí 2001 11:54 skrifaðir þú:
On Thu, Jul 19, 2001 at 11:24:05PM +0200, ob_ok@gmx.net wrote:
I would like the appearance of the LS output to be like under good old dos with "doscmd=/o:gen" or "dir /o:gen", that is directories sorted in a-z order FIRST, then the a-z sorted FILES.
I don't think there is a way to do this directly; you'll have to do it in a script. You could:
a) use perl: opendir, readdir, closedir will allow you to read the contents of a directory (to get the ls listing) if(-d xxx) will tell you if an entry is a directory if(! -d xxx) will tell you if an entry is not a directory sort will sort the list into alphanumeric order. b) use a shell script with find: the options you want to look up are: -maxdepth should allow you to restrict your find to just one directory -type d will choose only directories ! -type d will choose only non-directories -ls will run a form of ls on the result or -exec ls <options> '{}' \; will run whatever ls command you want on the result
HTH...
ls -l | grep ^d | sort -k 9 ; ls -l | grep -v ^d | sort -k 9 -tosi