按列 sort 排序 Linux 如何查看当前占用CPU或内存最多的K个进程

时间:2022-01-19 17:24:02

用法:sort [选项]... [文件]...
Write sorted concatenation of all FILE(s) to standard output.

长选项必须用的参数在使用短选项时也是必须的。
顺序选项:

-b, --ignore-leading-blanks ignore leading blanks
-d, --dictionary-order consider only blanks and alphanumeric characters
-f, --ignore-case fold lower case to upper case characters
-g, --general-numeric-sort compare according to general numerical value
-i, --ignore-nonprinting consider only printable characters
-M, --month-sort compare (unknown) < `JAN' < ... < `DEC'
-n, --numeric-sort compare according to string numerical value
-r, --reverse reverse the result of comparisons

Other options:

-c, --check check whether input is sorted; do not sort
-k, --key=POS1[,POS2] start a key at POS1, end it at POS2 (origin 1)
-m, --merge merge already sorted files; do not sort
-o, --output=FILE write result to FILE instead of standard output
-s, --stable stabilize sort by disabling last-resort comparison
-S, --buffer-size=SIZE use SIZE for main memory buffer
-t, --field-separator=SEP use SEP instead of non-blank to blank transition
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or /tmp;
multiple options specify multiple directories
-u, --unique with -c, check for strict ordering;
without -c, output only the first of an equal run
-z, --zero-terminated end lines with 0 byte, not newline
--help 显示此帮助信息并退出
--version 输出版本信息并退出

ps aux|sort -k3nr|grep "^resin" |head -2

sort -t  选项可以手工指定分隔符号

--------------------------------------------

[test@linux]$ cat aa
3 5
1 1
3 2
[test@linux]$ cat aa|sort -k2      2指第2列
1 1
3 2
3 5
[test@linux]$ cat aa|sort -k2r     r 倒序 reverse
3 5
3 2
1 1
[test@linux]$ cat aa|sort -k1r     1指第一列
3 5
3 2
1 1
[test@linux]$ cat aa|sort -k1
1 1
3 2
3 5

https://zhidao.baidu.com/question/371525749314218684.html