Grouping hidden files and directories with ls
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
How can ls
be flagged to sort .
-prefixed hidden directories and files in groups so that its output is sorted as visible directories, hidden directories, visible files, then hidden files?
I currently have ls aliased to ls -lG --color --group-directories-first
which groups directories first, but visible and hidden directories are mixed together.
Instead, the output of ls
should be:
visibleDirectoryA
visibleDirectoryB
.hiddenDirectoryA
.hiddenDirectoryB
visibleFileA
visibleFileB
.hiddenFileA
.hiddenFileB
files ls sort dot-files
add a comment |Â
up vote
0
down vote
favorite
How can ls
be flagged to sort .
-prefixed hidden directories and files in groups so that its output is sorted as visible directories, hidden directories, visible files, then hidden files?
I currently have ls aliased to ls -lG --color --group-directories-first
which groups directories first, but visible and hidden directories are mixed together.
Instead, the output of ls
should be:
visibleDirectoryA
visibleDirectoryB
.hiddenDirectoryA
.hiddenDirectoryB
visibleFileA
visibleFileB
.hiddenFileA
.hiddenFileB
files ls sort dot-files
i can reproduce, with localeen_AU.UTF8
. BTW,LANG=C ls ....
fails to reproduce (and, in fact, will even sort a directory name like!foo
before any of the .hidden directories - strict ascii value sort rather than a natural sort).
â cas
Jan 13 at 6:19
My locale output isLANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
â infosmith
Jan 13 at 6:56
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How can ls
be flagged to sort .
-prefixed hidden directories and files in groups so that its output is sorted as visible directories, hidden directories, visible files, then hidden files?
I currently have ls aliased to ls -lG --color --group-directories-first
which groups directories first, but visible and hidden directories are mixed together.
Instead, the output of ls
should be:
visibleDirectoryA
visibleDirectoryB
.hiddenDirectoryA
.hiddenDirectoryB
visibleFileA
visibleFileB
.hiddenFileA
.hiddenFileB
files ls sort dot-files
How can ls
be flagged to sort .
-prefixed hidden directories and files in groups so that its output is sorted as visible directories, hidden directories, visible files, then hidden files?
I currently have ls aliased to ls -lG --color --group-directories-first
which groups directories first, but visible and hidden directories are mixed together.
Instead, the output of ls
should be:
visibleDirectoryA
visibleDirectoryB
.hiddenDirectoryA
.hiddenDirectoryB
visibleFileA
visibleFileB
.hiddenFileA
.hiddenFileB
files ls sort dot-files
edited Jan 13 at 13:21
Jeff Schaller
31.8k848109
31.8k848109
asked Jan 13 at 5:38
infosmith
32
32
i can reproduce, with localeen_AU.UTF8
. BTW,LANG=C ls ....
fails to reproduce (and, in fact, will even sort a directory name like!foo
before any of the .hidden directories - strict ascii value sort rather than a natural sort).
â cas
Jan 13 at 6:19
My locale output isLANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
â infosmith
Jan 13 at 6:56
add a comment |Â
i can reproduce, with localeen_AU.UTF8
. BTW,LANG=C ls ....
fails to reproduce (and, in fact, will even sort a directory name like!foo
before any of the .hidden directories - strict ascii value sort rather than a natural sort).
â cas
Jan 13 at 6:19
My locale output isLANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
â infosmith
Jan 13 at 6:56
i can reproduce, with locale
en_AU.UTF8
. BTW, LANG=C ls ....
fails to reproduce (and, in fact, will even sort a directory name like !foo
before any of the .hidden directories - strict ascii value sort rather than a natural sort).â cas
Jan 13 at 6:19
i can reproduce, with locale
en_AU.UTF8
. BTW, LANG=C ls ....
fails to reproduce (and, in fact, will even sort a directory name like !foo
before any of the .hidden directories - strict ascii value sort rather than a natural sort).â cas
Jan 13 at 6:19
My locale output is
LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
â infosmith
Jan 13 at 6:56
My locale output is
LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
â infosmith
Jan 13 at 6:56
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Use -v
for natural sort. e.g.
ls -lG --color --group-directories-first -A -v
Note while they are sorted into their own "group", the .hidden directories will appear before the visible directories, not after them, because a .
sorts lower than most other characters.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Use -v
for natural sort. e.g.
ls -lG --color --group-directories-first -A -v
Note while they are sorted into their own "group", the .hidden directories will appear before the visible directories, not after them, because a .
sorts lower than most other characters.
add a comment |Â
up vote
2
down vote
accepted
Use -v
for natural sort. e.g.
ls -lG --color --group-directories-first -A -v
Note while they are sorted into their own "group", the .hidden directories will appear before the visible directories, not after them, because a .
sorts lower than most other characters.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Use -v
for natural sort. e.g.
ls -lG --color --group-directories-first -A -v
Note while they are sorted into their own "group", the .hidden directories will appear before the visible directories, not after them, because a .
sorts lower than most other characters.
Use -v
for natural sort. e.g.
ls -lG --color --group-directories-first -A -v
Note while they are sorted into their own "group", the .hidden directories will appear before the visible directories, not after them, because a .
sorts lower than most other characters.
edited Jan 13 at 6:57
answered Jan 13 at 6:08
cas
37.7k44393
37.7k44393
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416747%2fgrouping-hidden-files-and-directories-with-ls%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
i can reproduce, with locale
en_AU.UTF8
. BTW,LANG=C ls ....
fails to reproduce (and, in fact, will even sort a directory name like!foo
before any of the .hidden directories - strict ascii value sort rather than a natural sort).â cas
Jan 13 at 6:19
My locale output is
LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
â infosmith
Jan 13 at 6:56