Operating System - Linux
1752812 Members
5969 Online
108789 Solutions
New Discussion юеВ

Re: make ls -al on linux look like ls -al on HP-UX

 
SOLVED
Go to solution
Masaki Birchmier
Frequent Advisor

make ls -al on linux look like ls -al on HP-UX

Here's a quick one hopefully,
I'm trying to figure out how to make
ls -al on Linux display like HP-UX so that the .files are displayed first in the list. I've tried various sort options, but don't know how to make the .files list first.


Would like to listing to be like...
.bashrc
.mozilla
dsamplefile

instead of ...
.bashrc
dsamplefile
.mozilla

Thanks in advance, Masaki
6 REPLIES 6
Paul Cross_1
Respected Contributor

Re: make ls -al on linux look like ls -al on HP-UX

closest I came was:
> ls -alXr
Dave Falloon
Trusted Contributor

Re: make ls -al on linux look like ls -al on HP-UX

Strange, I'm running a debian box and my ls output looks like this:

davef@styx:~$ ls -a
.
..
.alias
.bash_history
.bash_profile
.bashrc
.cshrc
.viminfo
Maildir
net.log
test
davef@styx:~$

Here's the version output:

davef@styx:~$ ls --version
ls (coreutils) 5.2.1
Written by Richard Stallman and David MacKenzie.

Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
davef@styx:~$

hope that helps,

--Dave

Clothes make the man, Naked people have little to no effect on society
Paul Cross_1
Respected Contributor

Re: make ls -al on linux look like ls -al on HP-UX

Here is my version info, and I get the same output as Masaki.

>ls --version
ls (coreutils) 4.5.3
Written by Richard Stallman and David MacKenzie.

Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Mike Stroyan
Honored Contributor
Solution

Re: make ls -al on linux look like ls -al on HP-UX

The sorting of file names depends on your current locale. You can change that by setting the LANG or LC_COLLATE environment variable.
You can check your current locale by running the 'locale' command.

LANG=C ls -al
LC_COLLATE=C ls -al
Masaki Birchmier
Frequent Advisor

Re: make ls -al on linux look like ls -al on HP-UX

Thanks everyone for your input, Mike your suggestion did the trick.
my LANG was set to "en_US.UTF-8"
once I set it to "C ls -al" with
export LANG="C ls -al"

It sorts the way I want with ls -al

One curiosity, I had the same result with
"C ls -al" or "Cls-al"

Masaki
Mike Stroyan
Honored Contributor

Re: make ls -al on linux look like ls -al on HP-UX

The line
LANG=C ls -al
is something that you can type at the shell prompt to run the "ls -al" command after setting the LANG environment variable to "C".

That syntax tells /usr/bin/sh to set an environment variable for the single command that you run. The variable will go back to its previous setting when you get back to the shell prompt. It is a handy way to try out settings that might cause unwanted behavior.

If you set LANG to "C ls -al" or "Cls-al" I would guess that the LANG is invalid and the sorting functions are falling back to the default locale, which happens to be "C".