美文网首页
【Linux】sort 命令使用

【Linux】sort 命令使用

作者: Bogon | 来源:发表于2023-10-13 18:09 被阅读0次
# sort  --help

Usage: sort [OPTION]... [FILE]...
  or:  sort [OPTION]... --files0-from=F
Write sorted concatenation of all FILE(s) to standard output.

Mandatory arguments to long options are mandatory for short options too.
Ordering options:

  -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'
  -h, --human-numeric-sort    compare human readable numbers (e.g., 2K 1G)
  -n, --numeric-sort          compare according to string numerical value
  -R, --random-sort           sort by random hash of keys
      --random-source=FILE    get random bytes from FILE
  -r, --reverse               reverse the result of comparisons
      --sort=WORD             sort according to WORD:
                                general-numeric -g, human-numeric -h, month -M,
                                numeric -n, random -R, version -V
  -V, --version-sort          natural sort of (version) numbers within text

Other options:

      --batch-size=NMERGE   merge at most NMERGE inputs at once;
                            for more use temp files
  -c, --check, --check=diagnose-first  check for sorted input; do not sort
  -C, --check=quiet, --check=silent  like -c, but do not report first bad line
      --compress-program=PROG  compress temporaries with PROG;
                              decompress them with PROG -d
      --debug               annotate the part of the line used to sort,
                              and warn about questionable usage to stderr
      --files0-from=F       read input from the files specified by
                            NUL-terminated names in file F;
                            If F is - then read names from standard input
  -k, --key=KEYDEF          sort via a key; KEYDEF gives location and type
  -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
      --parallel=N          change the number of sorts run concurrently to N
  -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     display this help and exit
      --version  output version information and exit

KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position, where F is a
field number and C a character position in the field; both are origin 1, and
the stop position defaults to the line's end.  If neither -t nor -b is in
effect, characters in a field are counted from the beginning of the preceding
whitespace.  OPTS is one or more single-letter ordering options [bdfgiMhnRrV],
which override global ordering options for that key.  If no key is given, use
the entire line as the key.

SIZE may be followed by the following multiplicative suffixes:
% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y.

With no FILE, or when FILE is -, read standard input.

*** WARNING ***
The locale specified by the environment affects sort order.
Set LC_ALL=C to get the traditional sort order that uses
native byte values.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'sort invocation'

注意事项 :

1、排序时,默认是按每行/每个域的首字符排序,数字的优先级要大于字符的优先级

2、不指定升序还是降序时,默认是升序

参考

Linux sort命令深入解析
https://blog.csdn.net/succing/article/details/120742670

Linux sort命令用法
https://www.cnblogs.com/su-root/p/10995215.html

Linux tr命令使用方法
https://www.cnblogs.com/linyfeng/p/9075062.html

相关文章

  • sort 命令详解

    在linux系统使用过程中,提供了sort排序命令,支持常用的排序功能。 常用参数 sort命令支持很多参数,常用...

  • linux命令之uniq命令

    linux 命令 之 uniq命令是用于忽略或报告文件中的重复行,一般与sort命令结合使用 uniq命令可以加参...

  • 常用命令: sort学习笔记

    本文的sort命令是GNU版本(8.22), 和BSD的sort不同 sort是我最常用Linux命令之一,它的功...

  • awk命令

    下文来自:美团 吴孟达更多AWK命令请参考:Linux awk 命令扩展:linux sort,uniq,cut,...

  • Linux命令学习之:sort命令

    Linux命令学习之:sort命令 sort 命令对 File 参数指定的文件中的行排序,并将结果写到标准输出。如...

  • sort命令必知必会

    sort命令是linux系统里用来给文本排序的命令,使用频率很高。在日常使用时,有以下需要注意事项 1. 排序时候...

  • linux命令 - sort

    功能 sort or merge records (lines) of text and binary files

  • PHP高手进阶指南

    Linux常用命令 grep、awk、sed、sort、uniq、ps、df Linux系统性能分析 vmstat...

  • sort命令讲解

    sort命令是在Linux里非常有用,它将文件进行排序,并将排序结果标准输出。sort命令既可以从特定的文件,也可...

  • Linux排序命令sort笔记

    很多时候Linux需要对文本相对比较规范的文本数据进行排序,这时候可以使用Linux系统下的sort命令进行处理。...

网友评论

      本文标题:【Linux】sort 命令使用

      本文链接:https://www.haomeiwen.com/subject/syjabdtx.html