Question

I need to sort some files containing Chinese strings using zh_CN.utf8 while my system is in en_US.utf8.

For instance I have test.csv :

4001,动词,動詞,dong4ci2
4000,不然,不然,bu4ran2
3999,规格,規格,gui1ge2
3998,抽出,抽出,chou1chu1
3997,浮水印,浮水印,fu2shui3yin4
3996,拖曳與贴上,拖曳與貼上,tuo1ye4yu3tie1shang4
3995,云端运算,雲端運算,yun2duan1yun4suan4
3994,字集,字集,zi4ji2
3993,内码,內碼,nei4ma3
3992,兼容,兼容,jian1rong2

I'm trying to sort by simplified chinese, i.e. 2nd field, as follow:

sort -t ',' -d -k 2 test.csv

So how would I specify a locale only for the sort ?

Was it helpful?

Solution

Set LC_ALL temporarily like this:

LC_ALL=zh_CN.utf8 sort -t ',' -d -k 2 test.csv
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top