linux - 反向排序文件中的第三个数字列

标签 linux bash shell sorting command-line-interface

在 bash shell 脚本中,我有 users.txt 文件。

sort -t: -k 3n users.txt 给我



gg:g@g.g:
ff:f@f.f:5
gdr:d@sd.ds:5
g:w@f.com:8
r:w@d.com:85
qaws:aaa@d.com:789
qaz:a@s.com:789
vcf:d@c.com:855
op:popo@ppoo.po:6465
zx:a@c.com:7845
az:a@aa.com:7894
w:a@a.com:7894
h:g@g.com:7899
lp:l@l.com:8888
t:s@s.com:85474
dssdfsdf:fssdf@mbhkj.sdf:654654
u:f@g.comn:6546546
a:a@a.com:7894561
tt:t@t.t:1234567890

没关系。但我需要第 3 列,其中仅包含倒序的电话号码,即降序。如何实现?

我需要喜欢

tt:t@t.t:1234567890
a:a@a.com:7894561
u:f@g.comn:6546546
dssdfsdf:fssdf@mbhkj.sdf:654654
t:s@s.com:85474
lp:l@l.com:8888
and so on...

最佳答案

您可以在订单列规范中添加 r(“reverse”的缩写):

$ sort -t: -k 3nr  users.txt
# Here ---------^

关于linux - 反向排序文件中的第三个数字列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55578782/

相关文章:

node.js - 如何从 NodeJS 应用程序正确运行 bash 脚本?

json - 配置 Visual Studio Code 任务以顺序执行多个 shell 命令

c - Linux C-keyMapping keyCodes

linux - 为什么某些 "if"测试在我的 cron 脚本中不起作用

python - C++ 等同于 Linux 中 Python 的 time.time()?

bash - Shell-以大写形式导出变量名称

shell - 没有这样的文件或目录 (ls) 与波浪号扩展一起使用

linux - 如何终止 shell 脚本中的 fork 进程?

c - mmap 无效参数错误

c - char的返回链 - C中的getgrouplist