让linux Sort 按照 ASCII 顺序排序

1.

#cat test.tmp

101.16.109.61 121230012020887483

101.16.109.6 130129103337518683 

101.16.109.62 121127113043951234

101.16.109.6 221103013246294953 

101.16.109.66 130307204231337635

101.16.109.67 121230012020887483

101.16.109.67 201212220213191952

2.

#sort test.tmp

101.16.109.61 121230012020887483 

101.16.109.6 130129103337518683 

101.16.109.62 121127113043951234 

101.16.109.6 221103013246294953 

101.16.109.66 130307204231337635 

101.16.109.67 121230012020887483 

101.16.109.67 201212220213191952 


3.

#LC_ALL=C; export LC_ALL

4.

#sort test.tmp

101.16.109.6 130129103337518683 

101.16.109.6 221103013246294953 

101.16.109.61 121230012020887483 

101.16.109.62 121127113043951234 

101.16.109.66 130307204231337635 

101.16.109.67 121230012020887483 

101.16.109.67 201212220213191952 


分析:

在2中的sort时,man sort中说“*** WARNING *** The locale specified by the environment affects sort order.”,所以在3中修改了LC_ALL并export,然后在4中sort就的到了预期的效果了



你可能感兴趣的:(linux学习,shell编程)