相关疑难解决方法(0)

使用 LC_COLLATE 指定排序顺序,因此小写在大写之前

鉴于文件:

$ cat file
1
a
C
B
2
c
3
A
b
Run Code Online (Sandbox Code Playgroud)

默认情况下sort将:

$ sort file
1
2
3
a
A
b
B
c
C
Run Code Online (Sandbox Code Playgroud)

使用LC_COLLATE=Cso 将在小写之前按大写字母排序:

$ LC_COLLATE=C sort file
1
2
3
A
B
C
a
b
c
Run Code Online (Sandbox Code Playgroud)

是否可以通过排序来反转大小写顺序,即数字,小写然后大写?

linux sort

21
推荐指数
2
解决办法
4万
查看次数

`ls` 别名中的名称字母顺序与 .files 不混合

我目前使用以下ls别名:alias ls='ls -alhGkpsq --color=auto'. 这导致以下目录列表。

[03:35] bryson@brys  ~ :$ ls
total 48K
4.0K drwx------ 4 bryson 4.0K Nov  2 03:34 ./
8.0K drwxr-xr-x 3 root   4.0K Apr 19  2012 ../
4.0K -rw------- 1 bryson  676 Nov  2 03:35 .bash_history
8.0K -rw-r--r-- 1 bryson   21 Nov 23  2011 .bash_logout
8.0K -rw-r--r-- 1 bryson   57 Nov 23  2011 .bash_profile
4.0K -rw------- 1 bryson   50 Nov  2 03:34 .lesshst
4.0K drwxr-xr-x 3 bryson 4.0K Nov  2 03:21 source/
4.0K …
Run Code Online (Sandbox Code Playgroud)

linux ls sort locale dot-files

6
推荐指数
1
解决办法
530
查看次数

壳吃`?`字符

这是一个如此简单的问题,我确定有人问过它,但我找不到。我的外壳,我没有故意设置这样做,似乎吃任何涉及问号的词:

$ bash --version
GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin13.4.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ echo a ? = =?
a =

$ not-a-command? echo a
a

$ (?) echo a
a
Run Code Online (Sandbox Code Playgroud)

如果它很重要,请注意任何包含问号的单词似乎完全无声地消失了 - 在某种程度上,她的 shell 甚至从未注意到调用以未指定有效可执行文件的单词开头 - 即使问号是不是一开始。

shell bash special-characters quoting

1
推荐指数
1
解决办法
1432
查看次数

在 Linux 上使用 ls 按字母顺序对文件进行排序?

我正在尝试在 Ubuntu Xenial 中按自然顺序按字母顺序对文件(包括隐藏文件)进行排序。

我得到了这个:

ls -l1va
Run Code Online (Sandbox Code Playgroud)

哪个打印:

.
..
.ICEauthority
.Private
.Xauthority
.atom
.babel.json
.bashrc
.bash_history
.bash_logout
.cache
.cargo
.config
.dbeaver4
.dbeaver-drivers
.dbus
.docker
.eclipse
.ecryptfs
.electron
.fltk
.gconf
.gem
.gimp-2.8
.gitconfig
.gksu.lock
.gnome
.gnome2
.gnome2_private
.gnupg
.local
.mozilla
.nano
.node-gyp
.npm
.nvm
.pki
.profile
.putty
.recently-used
.selected_editor
.ssh
.sudo_as_admin_successful
.thumbnails
.v8flags.6.2.414.32-node.8.4654dce123559e380233361202560f0e.json
.vmware
.vscode
.vscode-insiders
.wget-hsts
.xsession-errors
.xsession-errors.old
.yarn
.yarnrc
Desktop
Documents
Downloads
Music
Pictures
Projects
Public
Templates
Videos
bin
mnt
tmp
Run Code Online (Sandbox Code Playgroud)

我怎样才能让排序不区分大小写并按字母排序而不是在 ASCII 表中的位置(我认为这是使 Z 在 a 之前的原因)..?

linux ls ubuntu sort

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

linux ×3

sort ×3

ls ×2

bash ×1

dot-files ×1

locale ×1

quoting ×1

shell ×1

special-characters ×1

ubuntu ×1