[英]how to use Linux command Sort to sort the text file according to 4th column, numeric order?
[英]How can I use sort command to sort the log file only by the first field in Linux?
我有一個名為a.log
的日志文件! 我希望通過fisrt字段排序! 如果兩行具有相同的字段,則順序為原始競爭對象!內容:
1. 101 c
2. 100 b
3. 100 a
4. 2 d
我期待結果:
1. 2 d
2. 100 b
3. 100 a
4. 101 c
所以我用這個命令!
sort -nt 't' -k 1 a.log
但結果是:
1. 2 d
2. 100 a
3. 100 b
4. 101 c
非常感謝!
你忘了約束關鍵字段了。 默認情況下,它一直使用到行尾。
sort -nst '\t' -k 1,1 0507.log
看一下手冊頁進行排序 ......
`-n`, --numeric-sort
compare according to string numerical value
所以這是一個例子......
sort -n filename
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.