/bin/ls output does not match manpage












7















ls manpage says:



List  information  about  the FILEs (the current directory by
default). Sort entries alphabetically if none of -cftuvSUX nor --sort
is specified.


and



-a, --all    do not ignore entries starting with .


and



-1     list one file per line.


but



/bin/ls -a1


lists entries alphabetically by the filename with any leading . removed, which is not alphabetically.



The sort command does the same.



Is there any way to get ls to work the normal way (with . files first - which isn't alphabetic either)?










share|improve this question




















  • 4





    The period isn't in the alphabet, hence it's locale-dependent, per steeldriver's answer.

    – wjandrea
    13 hours ago











  • You do understand that files and folders that start with . are hidden, correct?

    – Terrance
    12 hours ago








  • 1





    I think that's why the OP uses the -a option.

    – Arronical
    11 hours ago











  • It's doing exactly what it says in the man page: sorting the files alphabetically. It sounds like you want them sorted in ASCIIbetical order instead.

    – Mark
    4 hours ago
















7















ls manpage says:



List  information  about  the FILEs (the current directory by
default). Sort entries alphabetically if none of -cftuvSUX nor --sort
is specified.


and



-a, --all    do not ignore entries starting with .


and



-1     list one file per line.


but



/bin/ls -a1


lists entries alphabetically by the filename with any leading . removed, which is not alphabetically.



The sort command does the same.



Is there any way to get ls to work the normal way (with . files first - which isn't alphabetic either)?










share|improve this question




















  • 4





    The period isn't in the alphabet, hence it's locale-dependent, per steeldriver's answer.

    – wjandrea
    13 hours ago











  • You do understand that files and folders that start with . are hidden, correct?

    – Terrance
    12 hours ago








  • 1





    I think that's why the OP uses the -a option.

    – Arronical
    11 hours ago











  • It's doing exactly what it says in the man page: sorting the files alphabetically. It sounds like you want them sorted in ASCIIbetical order instead.

    – Mark
    4 hours ago














7












7








7








ls manpage says:



List  information  about  the FILEs (the current directory by
default). Sort entries alphabetically if none of -cftuvSUX nor --sort
is specified.


and



-a, --all    do not ignore entries starting with .


and



-1     list one file per line.


but



/bin/ls -a1


lists entries alphabetically by the filename with any leading . removed, which is not alphabetically.



The sort command does the same.



Is there any way to get ls to work the normal way (with . files first - which isn't alphabetic either)?










share|improve this question
















ls manpage says:



List  information  about  the FILEs (the current directory by
default). Sort entries alphabetically if none of -cftuvSUX nor --sort
is specified.


and



-a, --all    do not ignore entries starting with .


and



-1     list one file per line.


but



/bin/ls -a1


lists entries alphabetically by the filename with any leading . removed, which is not alphabetically.



The sort command does the same.



Is there any way to get ls to work the normal way (with . files first - which isn't alphabetic either)?







command-line ls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 13 hours ago









Melebius

5,03752040




5,03752040










asked 14 hours ago









David LedgerDavid Ledger

383




383








  • 4





    The period isn't in the alphabet, hence it's locale-dependent, per steeldriver's answer.

    – wjandrea
    13 hours ago











  • You do understand that files and folders that start with . are hidden, correct?

    – Terrance
    12 hours ago








  • 1





    I think that's why the OP uses the -a option.

    – Arronical
    11 hours ago











  • It's doing exactly what it says in the man page: sorting the files alphabetically. It sounds like you want them sorted in ASCIIbetical order instead.

    – Mark
    4 hours ago














  • 4





    The period isn't in the alphabet, hence it's locale-dependent, per steeldriver's answer.

    – wjandrea
    13 hours ago











  • You do understand that files and folders that start with . are hidden, correct?

    – Terrance
    12 hours ago








  • 1





    I think that's why the OP uses the -a option.

    – Arronical
    11 hours ago











  • It's doing exactly what it says in the man page: sorting the files alphabetically. It sounds like you want them sorted in ASCIIbetical order instead.

    – Mark
    4 hours ago








4




4





The period isn't in the alphabet, hence it's locale-dependent, per steeldriver's answer.

– wjandrea
13 hours ago





The period isn't in the alphabet, hence it's locale-dependent, per steeldriver's answer.

– wjandrea
13 hours ago













You do understand that files and folders that start with . are hidden, correct?

– Terrance
12 hours ago







You do understand that files and folders that start with . are hidden, correct?

– Terrance
12 hours ago






1




1





I think that's why the OP uses the -a option.

– Arronical
11 hours ago





I think that's why the OP uses the -a option.

– Arronical
11 hours ago













It's doing exactly what it says in the man page: sorting the files alphabetically. It sounds like you want them sorted in ASCIIbetical order instead.

– Mark
4 hours ago





It's doing exactly what it says in the man page: sorting the files alphabetically. It sounds like you want them sorted in ASCIIbetical order instead.

– Mark
4 hours ago










1 Answer
1






active

oldest

votes


















11














The order is determined by the collation sequence of your locale.



Ex. in my default locale (which is en_CA.UTF-8)



$ ls -A1
a
.b
c


whereas in the C locale



$ LC_COLLATE=C ls -A1
.b
a
c


(I used -A instead of -a to eliminate the . and .. directories).





Another way to get the order you want might be to use the -v (version sort) option as suggested in Grouping hidden files and directories with ls - although that's not really what it is intended for:




  -v     natural sort of (version) numbers within text



Since ls is almost certainly already aliased inside your .bashrc file, you could simply modify the alias(es) there to include the -v.






share|improve this answer


























  • None of my LC_ variables are set. I'm surprised that the default does something complicated rather something simple. LC_ALL=C now in my startup files.

    – David Ledger
    13 hours ago






  • 1





    @DavidLedger to see your locale settings, type locale (they don't appear explicitly as environment variables unless you set them as such)

    – steeldriver
    13 hours ago











  • Yes, that was set to en_US.UTF-8 I'm a shell person since '83, so locale generally makes no difference at all. Thanks.

    – David Ledger
    13 hours ago













  • Try adding export LC_ALL=C to your .profile.

    – John Wiersba
    4 hours ago













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1125597%2fbin-ls-output-does-not-match-manpage%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









11














The order is determined by the collation sequence of your locale.



Ex. in my default locale (which is en_CA.UTF-8)



$ ls -A1
a
.b
c


whereas in the C locale



$ LC_COLLATE=C ls -A1
.b
a
c


(I used -A instead of -a to eliminate the . and .. directories).





Another way to get the order you want might be to use the -v (version sort) option as suggested in Grouping hidden files and directories with ls - although that's not really what it is intended for:




  -v     natural sort of (version) numbers within text



Since ls is almost certainly already aliased inside your .bashrc file, you could simply modify the alias(es) there to include the -v.






share|improve this answer


























  • None of my LC_ variables are set. I'm surprised that the default does something complicated rather something simple. LC_ALL=C now in my startup files.

    – David Ledger
    13 hours ago






  • 1





    @DavidLedger to see your locale settings, type locale (they don't appear explicitly as environment variables unless you set them as such)

    – steeldriver
    13 hours ago











  • Yes, that was set to en_US.UTF-8 I'm a shell person since '83, so locale generally makes no difference at all. Thanks.

    – David Ledger
    13 hours ago













  • Try adding export LC_ALL=C to your .profile.

    – John Wiersba
    4 hours ago


















11














The order is determined by the collation sequence of your locale.



Ex. in my default locale (which is en_CA.UTF-8)



$ ls -A1
a
.b
c


whereas in the C locale



$ LC_COLLATE=C ls -A1
.b
a
c


(I used -A instead of -a to eliminate the . and .. directories).





Another way to get the order you want might be to use the -v (version sort) option as suggested in Grouping hidden files and directories with ls - although that's not really what it is intended for:




  -v     natural sort of (version) numbers within text



Since ls is almost certainly already aliased inside your .bashrc file, you could simply modify the alias(es) there to include the -v.






share|improve this answer


























  • None of my LC_ variables are set. I'm surprised that the default does something complicated rather something simple. LC_ALL=C now in my startup files.

    – David Ledger
    13 hours ago






  • 1





    @DavidLedger to see your locale settings, type locale (they don't appear explicitly as environment variables unless you set them as such)

    – steeldriver
    13 hours ago











  • Yes, that was set to en_US.UTF-8 I'm a shell person since '83, so locale generally makes no difference at all. Thanks.

    – David Ledger
    13 hours ago













  • Try adding export LC_ALL=C to your .profile.

    – John Wiersba
    4 hours ago
















11












11








11







The order is determined by the collation sequence of your locale.



Ex. in my default locale (which is en_CA.UTF-8)



$ ls -A1
a
.b
c


whereas in the C locale



$ LC_COLLATE=C ls -A1
.b
a
c


(I used -A instead of -a to eliminate the . and .. directories).





Another way to get the order you want might be to use the -v (version sort) option as suggested in Grouping hidden files and directories with ls - although that's not really what it is intended for:




  -v     natural sort of (version) numbers within text



Since ls is almost certainly already aliased inside your .bashrc file, you could simply modify the alias(es) there to include the -v.






share|improve this answer















The order is determined by the collation sequence of your locale.



Ex. in my default locale (which is en_CA.UTF-8)



$ ls -A1
a
.b
c


whereas in the C locale



$ LC_COLLATE=C ls -A1
.b
a
c


(I used -A instead of -a to eliminate the . and .. directories).





Another way to get the order you want might be to use the -v (version sort) option as suggested in Grouping hidden files and directories with ls - although that's not really what it is intended for:




  -v     natural sort of (version) numbers within text



Since ls is almost certainly already aliased inside your .bashrc file, you could simply modify the alias(es) there to include the -v.







share|improve this answer














share|improve this answer



share|improve this answer








edited 12 hours ago

























answered 14 hours ago









steeldriversteeldriver

69.2k11114185




69.2k11114185













  • None of my LC_ variables are set. I'm surprised that the default does something complicated rather something simple. LC_ALL=C now in my startup files.

    – David Ledger
    13 hours ago






  • 1





    @DavidLedger to see your locale settings, type locale (they don't appear explicitly as environment variables unless you set them as such)

    – steeldriver
    13 hours ago











  • Yes, that was set to en_US.UTF-8 I'm a shell person since '83, so locale generally makes no difference at all. Thanks.

    – David Ledger
    13 hours ago













  • Try adding export LC_ALL=C to your .profile.

    – John Wiersba
    4 hours ago





















  • None of my LC_ variables are set. I'm surprised that the default does something complicated rather something simple. LC_ALL=C now in my startup files.

    – David Ledger
    13 hours ago






  • 1





    @DavidLedger to see your locale settings, type locale (they don't appear explicitly as environment variables unless you set them as such)

    – steeldriver
    13 hours ago











  • Yes, that was set to en_US.UTF-8 I'm a shell person since '83, so locale generally makes no difference at all. Thanks.

    – David Ledger
    13 hours ago













  • Try adding export LC_ALL=C to your .profile.

    – John Wiersba
    4 hours ago



















None of my LC_ variables are set. I'm surprised that the default does something complicated rather something simple. LC_ALL=C now in my startup files.

– David Ledger
13 hours ago





None of my LC_ variables are set. I'm surprised that the default does something complicated rather something simple. LC_ALL=C now in my startup files.

– David Ledger
13 hours ago




1




1





@DavidLedger to see your locale settings, type locale (they don't appear explicitly as environment variables unless you set them as such)

– steeldriver
13 hours ago





@DavidLedger to see your locale settings, type locale (they don't appear explicitly as environment variables unless you set them as such)

– steeldriver
13 hours ago













Yes, that was set to en_US.UTF-8 I'm a shell person since '83, so locale generally makes no difference at all. Thanks.

– David Ledger
13 hours ago







Yes, that was set to en_US.UTF-8 I'm a shell person since '83, so locale generally makes no difference at all. Thanks.

– David Ledger
13 hours ago















Try adding export LC_ALL=C to your .profile.

– John Wiersba
4 hours ago







Try adding export LC_ALL=C to your .profile.

– John Wiersba
4 hours ago




















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1125597%2fbin-ls-output-does-not-match-manpage%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy