文件列表:多個領域和數字排序
sysbench-size-256M-mode-rndrd-threads-1
sysbench-size-256M-mode-rndrd-threads-16
sysbench-size-256M-mode-rndrd-threads-4
sysbench-size-256M-mode-rndrd-threads-8
sysbench-size-256M-mode-rndrw-threads-1
sysbench-size-256M-mode-rndrw-threads-16
sysbench-size-256M-mode-rndrw-threads-4
sysbench-size-256M-mode-rndrw-threads-8
sysbench-size-256M-mode-rndwr-threads-1
sysbench-size-256M-mode-rndwr-threads-16
sysbench-size-256M-mode-rndwr-threads-4
sysbench-size-256M-mode-rndwr-threads-8
sysbench-size-256M-mode-seqrd-threads-1
sysbench-size-256M-mode-seqrd-threads-16
sysbench-size-256M-mode-seqrd-threads-4
sysbench-size-256M-mode-seqrd-threads-8
sysbench-size-256M-mode-seqwr-threads-1
sysbench-size-256M-mode-seqwr-threads-16
sysbench-size-256M-mode-seqwr-threads-4
sysbench-size-256M-mode-seqwr-threads-8
我謹模式(rndrd,rndwr等)對它們進行排序,然後數:
sysbench-size-256M-mode-rndrd-threads-1
sysbench-size-256M-mode-rndrd-threads-4
sysbench-size-256M-mode-rndrd-threads-8
sysbench-size-256M-mode-rndrd-threads-16
sysbench-size-256M-mode-rndrw-threads-1
sysbench-size-256M-mode-rndrw-threads-4
sysbench-size-256M-mode-rndrw-threads-8
sysbench-size-256M-mode-rndrw-threads-16
....
我已經試過了下面的循環,但它是由數排序,但我需要的序列,例如1,4,8,16:
$ for f in $(ls -1A); do echo $f; done | sort -t '-' -k 7n
編輯:
請注意,數字排序(N)的數量對其進行排序(1,1,1,1,4,4,4,4 ...),但我需要一個像1,4,8,16,1序列,4,8,16 ......
該命令被接受,但似乎悄悄忽略'N'(使用GNU排序8.20) – msw 2013-04-30 11:50:07
@msw:哎呀,我的錯誤。我mislpaced了'N'! – choroba 2013-04-30 11:52:35