简体   繁体   中英

how to sort file with hangul characters in linux?

I have file which contain many hangul characters. for example:

저
가
항
공
사

인
도
의
항
공
사

I want to use linux sort for sorting lines in file but sort doesn't work. It give me:

저
가
항
공
사
인
도
의
항
공
사

So, sort only sorts spaces. How to sort this?

This is related to the LANG environment variable of your system.

In order to sort hangul characters, LANG should be set to ko_KR.utf-8.

LANG=ko_KR.utf-8 sort tmp.txt

should suit your need:

가
공
공
도
사
사
의
인
저
항
항

:D

You should be aware of another Korean locale, ko_KR.euckr .

Recently, It seems most of distro uses ko_KR.utf-8 as default Korean locale but ko_KR.euckr is still used widely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM