![]() | 1 rwdy2008 2018-04-17 20:36:00 +08:00 via iPhone 看下异常行这个冒号是不是中文格式了 |
3 MeteorCat 2018-04-17 20:43:02 +08:00 via Android 是不是把 r 的 ascii 码也计算在里面变成 r 的 ascii+0 的 ascii 位数排序,试着剔除 r 开头看看 |
![]() | 4 bin456789 2018-04-17 20:49:42 +08:00 ![]() sed 's/^r//' 2.txt | sort -k1n -t ':' | sed 's/^/r/' 勉强能用 |
![]() | 5 ant2017 2018-04-17 20:54:14 +08:00 ![]() cat 2.txt|sort -k 1.2n -t : |
![]() | 6 jasonyang9 2018-04-17 20:56:40 +08:00 EYDEF 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 over ride global ordering options for that key. If no key is given, use the entire line as the key. `man sort`中的这段看不懂,哪位能帮忙解释下并举几个例子?? |
![]() | 9 goreliu 2018-04-17 21:29:58 +08:00 ![]() 把 LANG 设置成 C,不然 sort 会出现各种奇怪现象。 % cat 2.txt | LANG=C sort -k1 -t ':' r0:26 r10:26 r11:26 r12:26 r13:26 r14:26 r1:26 |
![]() | 10 Lpl 2018-04-17 22:52:27 +08:00 ![]() https://stackoverflow.com/questions/6531674/linux-sort-unexpected-output?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa 这个回复说的挺好的,其实你的数据 ` r0:26 -> r026 r10:26 -> r1026 r11:26 -> r1226 r12:26 -> .... r1:26 r13:26 r14:26 ` 特殊字符会被忽略,然后按照字典序来进行排序 |
![]() | 11 goodryb 2018-04-17 23:41:22 +08:00 $cat 2.txt ;echo "----------" && cat 2.txt | sort -k1 -t ':' r0:26 r1:26 r10:26 r11:26 r12:26 r13:26 r14:26 ---------- r0:26 r10:26 r11:26 r12:26 r13:26 r14:26 r1:26 为啥我执行的结果和楼主不一样呢 |
![]() | 12 iwishing 2018-04-17 23:52:15 +08:00 字典序 r1226 r126 r1326 |
![]() | 13 guoer 2018-04-18 00:25:39 +08:00 少了个-n ? |