0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ロケールを無視して並べ替える(Unicode異体字など)

Last updated at Posted at 2024-10-27

sortコマンドはロケールを考慮してくれます。そのため異体字などが含まれる場合、並べ替えた順番が必ずしも同じにならないかもしれません。複数のファイルを全て同じ基準で並べ替えて比較したい場合には、それが妨げになる場合もあります。
そういう場合にはロケール(locale)を無視して、sortするように、ちょっとだけ工夫します。

LC_ALL=C sort file.txt

LC_ALL=C.utf8ではありません。LC_ALL=Cです。これによりutf-8などのロケール(locale)を考慮しない並べ替えになります。
以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?