Results 1 to 2 of 2

Thread: [SOLVED] [Solved] ls mixing sort order for dot files and case

  1. #1
    Join Date
    Jul 2007
    Beans
    2

    [SOLVED] [Solved] ls mixing sort order for dot files and case


    I like POSIX systems to display an 'ls' the old "normal way" - weighted: dot dirs/files before UpperCase. After the UC files, the LowerCase.

    Looking at the manpage or help for 'ls' is useless to resolve the "combining" issue. To make matters worse, terms like "ls sort dot files" etc will get you nowhere on Google.

    The fix is make sure your LANG or LC_COLLATE environmental variable(s) are set to "C". You can set this in a number of places: System wide, the user's rc scripts or aliased for specific commands.

    System Wide:

    If you set to your LANG or LC_COLLATE system wide, you'll have to set it TWO places. It will also require a reboot for it take effect. There's a reported Launchpad bug about this issue that also impact PAM

    https://bugs.launchpad.net/ubuntu/+s...pam/+bug/77983
    $LANG is defined in 2 places: /etc/environment and /etc/default/locale

    You'll want to comment out LANG="en_US.UTF-8" or whatever and add LANG="C". Alternatively, you could try just adding LC_COLLATE="C"

    # LANG="en_US.UTF-8"
    LANG="C"

    # or just add

    LC_COLLATE="C"

    Changing the system wide LANG could have unintended consequences though.

    Per user:

    This will override the system setting and is preferred.

    A user can edit their ~/.bashrc script to add either line:
    export LANG="C"
    # or
    export LC_COLLATE="C"

    This modification only affect that specific, existing user. If you want all new, future users to have this in their ~/.bashrc by default, then as root, you should add the updated environmental variables to the system wide /etc/skel/.bashrc file. The /etc/skel files are copied to every new user account.

    Per alias:

    Maybe you want to leave everything alone and wish to have your aliases deal with it specifically. Again, you can add these directly to your ~/.bashrc. Or even smarter, uncomment the .bash_aliases section in your ~/.bashrc file, create a ~/.bash_aliases file and add any of your personal aliases there.

    To set it just for ls, use either of the following:

    • alias ls='LC_COLLATE=C ls' # for non-color
    • alias ls='LC_COLLATE=C ls -F --color=auto' # for color


    Additional information:

    If you need additional information the other locale environmental variables, please consult:



    May this bring the desired order and alignment to your $HOME

    Later, markstinson
    Last edited by markstinson; June 3rd, 2008 at 06:26 AM. Reason: updated advance smiley and subscription options

  2. #2
    Join Date
    May 2008
    Location
    Montreal, Qc, Canada
    Beans
    412
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: [Solved] ls mixing sort order for dot files and case

    Thanks very much for the info

    To officially mark your post solved, please click on the Thread Tools link just above your post, then select Mark thread solved.

    Cheers,

    Z.
    Self-appointed Newbie Advocate & Honorary Authorized Troll
    Ubuntu is Freedom. Learn the basics, then enjoy shaping your own.
    Need a place to start? Look here. Get help.
    PLZ mark your [SOLVED] posts. L.U. #471967

Tags for this Thread

Bookmarks

Posting Permissions

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