Let's say I have a directory with the files _b, a, c, č, d. I would like to sort the files according to the cs_CZ.UTF8 locale but without ignoring the underscore, ie like this: _b a c č d.
Currently, ls (and ls | sort as well) sorts the files like this: a _b c č d.
All answers I have found suggest using LC_COLLATE=C, but that changes the ordering to
this: _b a c d č (notice that č is now at the end, not between c and d as it is supposed to be).
Is there any way to achieve this goal?
Note that I also care about other characters than underscore, ie I would like a-n.pdf a-p.pdf a.pdf c č d sort in this order and not a-n.pdf a.pdf a-p.pdf c č d.
(EDIT: Actually, a.pdf a-n.pdf a-p.pdf c č d is also fine, as long as the non-alphanumeric characters are not ignored.)
The following are not the answers I am looking for:
- using
LC_COLLATE=Cas explained above, - using shell expansion such as
ls _*; ls [^_]*because the question is not only about underscores.
[locale]tag also. Have you looked at unix.stackexchange.com/q/421908/90290 and unix.stackexchange.com/q/39827/90290 yet?a.pdf a-n.pdf a-p.pdfis OK, as isa-n.pdf a-p.pdf a.pdf, but nota-n.pdf a.pdf a-p.pdfas that clearly ignores the hyphens/periods. I have tried to clarify this in the question.