[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ls'ing dirs before files



> and sort also doesn't deal with the interspersing of dot-files with
> non-dot-files, which /bin/ls started doing along with interspersing
> directories and files ...
> 
> not a problem over here, just a curiousity.  anyone let us know if you
> figure it out.

It sounds like you are using a specific locale, which you probably
are, which specifies that characters like '.' are not significant in
the name.  That is often called dictionary order.  Use 'locale' to see
what locales you are set.

  locale

Try setting LC_ALL=POSIX for a test and you will see the standard
behavior.  For a test you don't have to do it permanently, just for
that one command.

  LC_ALL=POSIX ls -a

The ls and sort and other commands that collate are required by the
standards to respect locales.  They do whatever you tell them to do.

  http://www.unix-systems.org/single_unix_specification_v2/xcu/ls.html
  http://www.unix-systems.org/single_unix_specification_v2/xcu/sort.html

Those command just call strcoll(3) for the comparision.  So actually
the commands themselves have nothing to do with sort order
localization beyond that.  It all falls into the libc strcoll()
routine.  So in the end it is in the hands of libc.  Read this section
of the documentation on locales.

  info libc

Bob

Attachment: pgpmvN8Oyo4Ld.pgp
Description: PGP signature


Reply to: