Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools Text sort #31

Open
junxnone opened this issue Oct 25, 2019 · 0 comments
Open

Tools Text sort #31

junxnone opened this issue Oct 25, 2019 · 0 comments

Comments

@junxnone
Copy link
Owner

junxnone commented Oct 25, 2019

sort 排序工具

  • sort 常用参数
  -b   忽略每行前面开始出的空格字符。
  -c   检查文件是否已经按照顺序排序。
  -f   排序时,忽略大小写字母。
  -M   将前面3个字母依照月份的缩写进行排序。
  -n   依照数值的大小排序。
  -o<输出文件>   将排序后的结果存入指定的文件。
  -r   以相反的顺序来排序。
  -t<分隔字符>   指定排序时所用的栏位分隔字符。
  -k  选择以哪个区间进行排序。

UseCase

去重复

当 ids.txt 里面包含较多重复的行时,可以使用 sort -u 去重复

cat ids.txt|sort -u 

sort 参数:
-u, --unique with -c, check for strict ordering; without -c, output only the first of an equal run

文件大小排序

du -h -d 1 .|sort -hr
@junxnone junxnone changed the title shell sort shell - sort May 4, 2020
@junxnone junxnone changed the title shell - sort Linux sort Sep 22, 2021
@junxnone junxnone transferred this issue from junxnone/Linux_archive Sep 22, 2021
@junxnone junxnone changed the title Linux sort Linux Tools sort Dec 18, 2022
@junxnone junxnone transferred this issue from junxnone/techwiki Dec 20, 2022
@junxnone junxnone changed the title Linux Tools sort Tools sort Dec 21, 2022
@junxnone junxnone changed the title Tools sort Tools Text sort Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant