簡體   English   中英

排序命令在Linux終端中以無序順序打印

[英]Sort command is printing in unordered sequence in linux terminal

我有一個名為temp的文件,以下是該文件中的數據

0.9
1
2
3
10
4
5
6

當我在終端中執行sort temp時,我得到的答案是

0.9
1
10
2
3
4
5

但我的預期答案是

0.9
1
2
3
4
5
10

有人可以幫我嗎?

man sort

  -n, --numeric-sort
          compare according to string numerical value

因此,使用

sort -n temp

默認情況下,該命令按“字典順序”排序

如果要數字訂購,請使用-n

sort -n file

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM