linux按文件名排序,linux按照文件后缀进行排序

服务器上面有很多文件,xxx.1,xxx2.1,xxxx3.1,yyy.2,yyy2.2yyy3.2,zzz.3,zzz2.3类似这样的,现在想安装文件的后缀对该文件进行排序,需要查看sort命令。

命令如下:ls |sort -n -t '.' -k2即可。

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

--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=POS1[,POS2] start a key at POS1 (origin 1), end it at POS2

(default end of line)

-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 display this help and exit

--version output version information and exit

POS is F[.C][OPTS], where F is the field number and C the character position

in the field; both are origin 1. 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, 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.

Report sort bugs to bug-coreutils@gnu.org

GNU coreutils home page:

General help using GNU software:

For complete documentation, run: info coreutils 'sort invocation'

统计数字后缀的数据量,命令:

find -regex  ".*\.[0-9]+$" | cut -f3 -d'.' | sort | uniq -c -i

效果如下了:

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值