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?

More than 3 years have passed since last update.

Linux 数字を含む文字列を数字の大小でソートする

Posted at

sort -V

サンプルファイル

sample.txt
1組     旅立ちの日に
11組    今日の日はさようなら
2組     翼をください

昇順 sort -V

$ sort -V sample.txt
1組     旅立ちの日に
2組     翼をください
11組    今日の日はさようなら

降順 sort -Vr

$ sort -Vr sample.txt
11組    今日の日はさようなら
2組     翼をください
1組     旅立ちの日に

辞書順 sort

$ sort sample.txt
11組    今日の日はさようなら
1組     旅立ちの日に
2組     翼をください
  -V, --version-sort          natural sort of (version) numbers within text

参考記事

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?