Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #200871 > unrolled thread
| Started by | Lee <ler762@gmail.com> |
|---|---|
| First post | 2018-10-03 17:10 +0200 |
| Last post | 2018-10-03 20:10 +0200 |
| Articles | 9 — 3 participants |
Back to article view | Back to linux.debian.user
ls -la sort order Lee <ler762@gmail.com> - 2018-10-03 17:10 +0200
Re: ls -la sort order Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-03 17:20 +0200
Re: ls -la sort order Lee <ler762@gmail.com> - 2018-10-03 18:40 +0200
Re: ls -la sort order Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-03 18:40 +0200
Re: ls -la sort order Roberto C. Sánchez <roberto@debian.org> - 2018-10-03 18:50 +0200
Re: ls -la sort order Lee <ler762@gmail.com> - 2018-10-03 20:00 +0200
Re: ls -la sort order Roberto C. Sánchez <roberto@debian.org> - 2018-10-03 20:10 +0200
Re: ls -la sort order Lee <ler762@gmail.com> - 2018-10-03 21:00 +0200
Re: ls -la sort order Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-03 20:10 +0200
| From | Lee <ler762@gmail.com> |
|---|---|
| Date | 2018-10-03 17:10 +0200 |
| Subject | ls -la sort order |
| Message-ID | <wEQWK-1Vn-9@gated-at.bofh.it> |
I really don't like that 'ls -la' seems to ignore a leading dot when sorting files for display - eg. in terminal I'll get old Pictures .profile Public I haven't changed any settings yet; I've still got LANG=en_US.utf8 I can fix the problem by aliasing ls to 'LC_COLLATE=C ls' but that seems klunky and would only fix ls (and not break anything else). How bad of an idea would it be to set LC_COLLATE=C in my .bashrc or is there some other setting to get dot files listed first, then uppercase, then lowercase? and I thought character codes 32-126 were the same thing in ascii and utf8, so why is this happening in the first place? Thanks, Lee
[toc] | [next] | [standalone]
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Date | 2018-10-03 17:20 +0200 |
| Message-ID | <wER6p-1Ys-7@gated-at.bofh.it> |
| In reply to | #200871 |
On Wed, Oct 03, 2018 at 11:07:04AM -0400, Lee wrote: > I can fix the problem by aliasing ls to 'LC_COLLATE=C ls' but that > seems klunky and would only fix ls (and not break anything else). How > bad of an idea would it be to set > LC_COLLATE=C > in my .bashrc or is there some other setting to get dot files listed > first, then uppercase, then lowercase? This will affect ls, and also the expansion of globs. It's totally fine, assuming this is what you want, and assuming you don't have a lot of files with non-ASCII characters in their names. This is exactly what locale settings are for. Don't forget to export it.
[toc] | [prev] | [next] | [standalone]
| From | Lee <ler762@gmail.com> |
|---|---|
| Date | 2018-10-03 18:40 +0200 |
| Message-ID | <wESlP-2D1-1@gated-at.bofh.it> |
| In reply to | #200872 |
On 10/3/18, Greg Wooledge <wooledg@eeg.ccf.org> wrote: > On Wed, Oct 03, 2018 at 11:07:04AM -0400, Lee wrote: >> I can fix the problem by aliasing ls to 'LC_COLLATE=C ls' but that >> seems klunky and would only fix ls (and not break anything else). How >> bad of an idea would it be to set >> LC_COLLATE=C >> in my .bashrc or is there some other setting to get dot files listed >> first, then uppercase, then lowercase? > > This will affect ls, and also the expansion of globs. interesting... I get different results for 'ls [D-M]*' if LC_COLLATE=C or LC_COLLATE=en_US.utf8 > It's totally fine, > assuming this is what you want, and assuming you don't have a lot of > files with non-ASCII characters in their names. I'm guessing no since I don't know how to create a filename with a non-ascii character :) > This is exactly what locale settings are for. cool.. Thank you Lee
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Date | 2018-10-03 18:40 +0200 |
| Message-ID | <wESlQ-2D1-9@gated-at.bofh.it> |
| In reply to | #200873 |
On Wed, Oct 03, 2018 at 12:31:01PM -0400, Lee wrote: > I'm guessing no since I don't know how to create a filename with a > non-ascii character :) This may/may not apply to you, but someone reading the archives may be interested: In X, you can type characters that are a superset of what's on your keyboard using the Compose feature. This is described (briefly) at <https://wiki.debian.org/XCompose>.
[toc] | [prev] | [next] | [standalone]
| From | Roberto C. Sánchez <roberto@debian.org> |
|---|---|
| Date | 2018-10-03 18:50 +0200 |
| Message-ID | <wESvv-2Gf-11@gated-at.bofh.it> |
| In reply to | #200873 |
On Wed, Oct 03, 2018 at 12:31:01PM -0400, Lee wrote: > > interesting... I get different results for 'ls [D-M]*' if LC_COLLATE=C > or LC_COLLATE=en_US.utf8 > Think of it this way: en_US.utf8 -> sort in alphabetical order C -> sort in ASCII-betical order In ASCII, all of the capital letters precede all of the lowercase letters. In US English, there is not a sorting distinction between a capital and its matching lowercase, so they are considered equivalent. Said another way, in ASCII 'A' != 'a', but en_US.utf8 'A' == 'a' (and probably in every locale that uses Latin-1 as a base). Regards, -Roberto -- Roberto C. Sánchez
[toc] | [prev] | [next] | [standalone]
| From | Lee <ler762@gmail.com> |
|---|---|
| Date | 2018-10-03 20:00 +0200 |
| Message-ID | <wETBg-3h4-7@gated-at.bofh.it> |
| In reply to | #200875 |
On 10/3/18, Roberto C. Sánchez <roberto@debian.org> wrote: > On Wed, Oct 03, 2018 at 12:31:01PM -0400, Lee wrote: >> >> interesting... I get different results for 'ls [D-M]*' if LC_COLLATE=C >> or LC_COLLATE=en_US.utf8 >> > Think of it this way: > > en_US.utf8 -> sort in alphabetical order > C -> sort in ASCII-betical order > > In ASCII, all of the capital letters precede all of the lowercase > letters. In US English, there is not a sorting distinction between a > capital and its matching lowercase, so they are considered equivalent. > Said another way, in ASCII 'A' != 'a', but en_US.utf8 'A' == 'a' (and > probably in every locale that uses Latin-1 as a base). Sure - I can understand some people wanting A a to sort together. But ignoring non-alpha characters when sorting??? Eventually I'm sure I can get used to Music old Pictures but this order is obnoxious .mozilla Music old Pictures .profile Public I don't think I'll ever get used to that. I'm just a bit concerned that setting LC_COLLATE=C is going to break something & I'll have a heck of a time figuring out it was because I changed the sort order. Regards, Lee
[toc] | [prev] | [next] | [standalone]
| From | Roberto C. Sánchez <roberto@debian.org> |
|---|---|
| Date | 2018-10-03 20:10 +0200 |
| Message-ID | <wETKV-3zv-3@gated-at.bofh.it> |
| In reply to | #200877 |
On Wed, Oct 03, 2018 at 01:51:54PM -0400, Lee wrote: > > Sure - I can understand some people wanting A a to sort together. But > ignoring non-alpha characters when sorting??? Eventually I'm sure I > can get used to > Music > old > Pictures > > but this order is obnoxious > .mozilla > Music > old > Pictures > .profile > Public > While it may not particularly intuitive, I would not call it obnoxious. In English, the '.' would not customarily be used to make lexical sorting decisions. Dr. Jiles Dr Jones Dr. Jurgenson That would be the sort order I expect (for English, or most any other natural language locale). Either of Dr Jones Dr. Jiles Dr. Jurgenson or Dr. Jiles Dr. Jurgenson Dr Jones would seem incorrect to me. I suspect that collation function has no way of knowing whether the punctuation is important or not, so it must adhere to the rules specified in the locale (to ignore it in this case). You could always write a custom locale that sorts punctuation before or after letters, as you like. The locale(5) man page would be a good place to start for that. > I don't think I'll ever get used to that. I'm just a bit concerned > that setting LC_COLLATE=C is going to break something & I'll have a > heck of a time figuring out it was because I changed the sort order. > Call me old school, but I have LC_COLLATE=C in every shell profile on every machine that I use. I find that sorting is most important to me at the shell prompt (and usually when using ls). There has never been instance where I encountered an oddity that I even suspected related to my choice of LC_COLLATE. Regards, -Roberto -- Roberto C. Sánchez
[toc] | [prev] | [next] | [standalone]
| From | Lee <ler762@gmail.com> |
|---|---|
| Date | 2018-10-03 21:00 +0200 |
| Message-ID | <wEUxj-3P0-3@gated-at.bofh.it> |
| In reply to | #200878 |
On 10/3/18, Roberto C. Sánchez <roberto@debian.org> wrote: > On Wed, Oct 03, 2018 at 01:51:54PM -0400, Lee wrote: >> >> Sure - I can understand some people wanting A a to sort together. But >> ignoring non-alpha characters when sorting??? Eventually I'm sure I >> can get used to >> Music >> old >> Pictures >> >> but this order is obnoxious >> .mozilla >> Music >> old >> Pictures >> .profile >> Public >> > > While it may not particularly intuitive, I would not call it obnoxious. > In English, the '.' would not customarily be used to make lexical > sorting decisions. > > Dr. Jiles > Dr Jones > Dr. Jurgenson > > That would be the sort order I expect (for English, or most any other > natural language locale). Which is probably why I'm having such a hard time accepting the en_US.utf8 sort order. I want the "computer" rules, not the natural language rules. > Either of > > Dr Jones > Dr. Jiles > Dr. Jurgenson > > or > > Dr. Jiles > Dr. Jurgenson > Dr Jones > > would seem incorrect to me. <grin> what seems incorrect to me is that the data isn't normalized. I'd do something like sed -e 's/^Dr /Dr. /' | sort > I suspect that collation function has no > way of knowing whether the punctuation is important or not, so it must > adhere to the rules specified in the locale (to ignore it in this case). > You could always write a custom locale that sorts punctuation before or > after letters, as you like. The locale(5) man page would be a good > place to start for that. ok - I'll take a look >> I don't think I'll ever get used to that. I'm just a bit concerned >> that setting LC_COLLATE=C is going to break something & I'll have a >> heck of a time figuring out it was because I changed the sort order. >> > > Call me old school, but I have LC_COLLATE=C in every shell profile on > every machine that I use. I find that sorting is most important to me > at the shell prompt (and usually when using ls). There has never been > instance where I encountered an oddity that I even suspected related to > my choice of LC_COLLATE. Good to know! Thank you Lee
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Date | 2018-10-03 20:10 +0200 |
| Message-ID | <wETKV-3zv-7@gated-at.bofh.it> |
| In reply to | #200877 |
On Wed, Oct 03, 2018 at 01:51:54PM -0400, Lee wrote: > I don't think I'll ever get used to that. I'm just a bit concerned > that setting LC_COLLATE=C is going to break something & I'll have a > heck of a time figuring out it was because I changed the sort order. As a user, it's your prerogative to set your locale variables however you like. Setting one of them to C is *always* permitted. All that matters is what you prefer. wooledg:~$ printf %s\\n o O oh Ohio ô Ô ó Ó | LC_COLLATE=C sort O Ohio o oh Ó Ô ó ô wooledg:~$ printf %s\\n o O oh Ohio ô Ô ó Ó | LC_COLLATE=en_US.utf8 sort o O ó Ó ô Ô oh Ohio
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web