2016-11-08 45 views
2

假設我有一個包含1列文件:如何在UNIX,然後再數字排序字母

1 
2 
a 
b 
0 

預期成果:

a 
b 
0 
1 
2 

如果我用那種獨自一人,其結果將成爲1-> 2-> a-> b這不是我想要的。 有沒有什麼辦法可以先排序字母,然後再數字?謝謝。

回答

1
sort -g <inputfile 
a 
b 
0 
1 
2 

附加例如:

cat inputfile 
1 
0 
2 
3 
sd 
35 
76 
23 
asd 


sort -g inputfile 
asd 
sd 
0 
1 
2 
3 
23 
35 
76 
+0

請將我的回答類似這樣的一個問題:http://stackoverflow.com/questions/40483463/how-to-sort-alphanumeric-column- in-unix-with-alphabet-first-and-then-numeric –

+0

已經嘗試過了。請檢查... –

相關問題