You are not logged in.
I don't know how to word what I want. So here's an example:
$ ls ~
.purple downloads .bashrc color.sh
Where .purple and downloads are directories.
I remember adding something to my .bashrc (in the distant past) to change the default behavior, but I believe it was an environment variable or something (as opposed to an option with ls).
Does anyone have information regarding this?
Edit:
The behavior I'm after is for directories and files beginning with a period to be shown first- as if alphabetically sorted but with "." being treated as being before a and 1.
Adding the following to .bashrc:
export LANG=PPOSIX
accomplishes this, but I don't really understand why. It also isn't the method I used the last time.
So my question is "Is there another way to do this, and, if not, can anyone explain how this works?"
Last edited by nsmartt (2012-05-20 21:36:39)
Offline
The thing you added to .bashrc was an alias. If you want more information, run
man aliasman lsmaybe in combination with some search engine.
Offline
The thing you added to .bashrc was an alias. If you want more information, run
man aliasman lsmaybe in combination with some search engine.
Thanks, but it wasn't an alias. That's why I mentioned that ls lacks an option to do this.
Edit:
I've tried searching for this (I found it the last time I was looking for this), but all I found was a thread about Fedora. Apparently, adding "export LANG=POSIX" works on Fedora, but running "LANG=POSIX ls" in terminal doesn't work as expected.
This is where I got with this edit before I decided to try adding "export LANG=POSIX" to my .bashrc (Which works, even though "LANG=POSIX ls" doesn't).
Will this cause any trouble in the long term since LANG exists/is being overwritten?
Edit 2:
export LANG=POSIX is not what I added the first time.
Last edited by nsmartt (2012-05-20 20:48:20)
Offline
You can do it by ussing the flag --group-directories-first
ls -la --group-directories-firstIf you want this behavior always, you have to create an Alias in your .bashrc
Offline
You can do it by ussing the flag --group-directories-first
ls -la --group-directories-firstIf you want this behavior always, you have to create an Alias in your .bashrc
Thanks, but I'm talking about files and directories preceded by a . being shown first, not directories first in general.
Offline
I don't know how to word what I want. So here's an example:
$ ls ~
.purple downloads .bashrc color.sh
On my box 'ls' doesn't show hidden files / directories at all, so I think you are using some kind of an alias.
Run
type -a lsto make sure.
$ ls -A
.1 .a .d .z 10 11 21 aa ab da
$ ls -Al
total 8
-rw-r--r-- 1 karol users 0 05-20 23:10 .1
-rw-r--r-- 1 karol users 0 05-20 23:10 .a
drwxr-xr-x 2 karol users 4096 05-20 23:10 .d
-rw-r--r-- 1 karol users 0 05-20 23:10 .z
-rw-r--r-- 1 karol users 0 05-20 23:10 10
-rw-r--r-- 1 karol users 0 05-20 23:10 11
-rw-r--r-- 1 karol users 0 05-20 23:10 21
-rw-r--r-- 1 karol users 0 05-20 23:10 aa
-rw-r--r-- 1 karol users 0 05-20 23:10 ab
drwxr-xr-x 2 karol users 4096 05-20 23:10 daI'm using
export LC_COLLATE="C"in my .bashrc.
Using different collation gives different results:
$ LC_COLLATE="pl_PL.UTF-8" ls -A
.1 10 11 21 .a aa ab .d da .zOffline
nsmartt wrote:I don't know how to word what I want. So here's an example:
$ ls ~
.purple downloads .bashrc color.shOn my box 'ls' doesn't show hidden files / directories at all, so I think you are using some kind of an alias.
Runtype -a lsto make sure.
$ ls -A .1 .a .d .z 10 11 21 aa ab da $ ls -Al total 8 -rw-r--r-- 1 karol users 0 05-20 23:10 .1 -rw-r--r-- 1 karol users 0 05-20 23:10 .a drwxr-xr-x 2 karol users 4096 05-20 23:10 .d -rw-r--r-- 1 karol users 0 05-20 23:10 .z -rw-r--r-- 1 karol users 0 05-20 23:10 10 -rw-r--r-- 1 karol users 0 05-20 23:10 11 -rw-r--r-- 1 karol users 0 05-20 23:10 21 -rw-r--r-- 1 karol users 0 05-20 23:10 aa -rw-r--r-- 1 karol users 0 05-20 23:10 ab drwxr-xr-x 2 karol users 4096 05-20 23:10 daI'm using
export LC_COLLATE="C"in my .bashrc.
Using different collation gives different results:$ LC_COLLATE="pl_PL.UTF-8" ls -A .1 10 11 21 .a aa ab .d da .z
I was using an alias to do ls -A by default. I forgot to say ls -A because I've gotten so used to it. My fault.
LC_COLLATE is exactly what I was trying to find. Thanks so much.
Time to find out what LC_COLLATE is.
Offline
Time to find out what LC_COLLATE is.
I found some info here: http://pubs.opengroup.org/onlinepubs/79 … nvvar.html
LC_COLLATE
This variable determines the locale category for character collation. It determines collation information for regular expressions and sorting (...)
Offline