Find the answer to your Linux question:
Results 1 to 4 of 4
When sorting files it seems that Linux (or at least the ls command), unlike Windows, ignores the underescore character. For example. ls diplayes "a" then "_b" then "c", while Windows ...
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Posts
    3

    sorting and the underscore character

    When sorting files it seems that Linux (or at least the ls command), unlike Windows, ignores the underescore character. For example. ls diplayes "a" then "_b" then "c", while Windows first displays "_b" then "a" then "c". Can somebody tell me why is that and how could I obtain the other behaviour?

    Thanks.

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    Use the option
    --sort=none
    with ls.

    For ex:
    ls -l --sort=none
    will do.
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Posts
    3
    Yes... but I want them sorted in lexicographic order (_<a<b<...). I don't understand why 'ls' ignores the underscore.

  4. #4
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    piping the output of 'ls' to 'sort' will do... but not in lexical order as u want...
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...