How can I sort file names by version numbers?

前端 未结 7 1183
轮回少年
轮回少年 2020-12-05 13:23

In the directory \"data\" are these files:

command-1.9a-setup
command-2.0a-setup
command-2.0c-setup
command-2.0-setup

7条回答
  •  有刺的猬
    2020-12-05 14:14

    Old post, but... ls -l --sort=version may be of assistance (although for OP's example the sort is the same as done by ls -l in a RHEL 7.2):

    command-1.9a-setup
    command-2.0a-setup
    command-2.0c-setup
    command-2.0-setup
    

    YMMV i guess.

提交回复
热议问题