开发者

Unix ls command file name sort (differently than default)

Chris-Muenchs-Mac-Book-Pro:database cmuench$ ls -1
database.sql
database_10.0-10.1.sql
database_10.1-10.2.sql
database_10.3-10.4.sql
database_10.4-10.5.sql
database_10.5-10.6.sql
database_10.9-11.0.sql
database_11.0-11.1.sql
database_11.1-11.2.sql
database_11.2-11.3.sql
database_11.6-12.0.sql
database_12.1-12.2.sql
database_12.11-12.12.sql
database_12.12-12.13.sql
database_12.13-12.14.sql
database_12.3-12.4.sql
database_12.4-12.5.sql
database_12.5-12.6.sql
database_12.9-12.10.sql

Is there a way to sort like this?

database.sql
database_10.0-10.1.sql
database_10.1-10.2.sql
database_10.3-10.4.sql
database_10.4-10.5.sql
database_10.5-10.6.sql
database_10.9-11.0.sql
database_11.0-11.1.sql
database_11.1-11.2.sql
database_11.2-11.3.sql
database_11.6-12.0.sql
database_12.1-12.2.sql
database_12.3-12.4.sql
database_12.4-12.5.sql
database_12.5-12.6.sql
database_12.9-12.10.sql
database开发者_StackOverflow_12.11-12.12.sql
database_12.12-12.13.sql
database_12.13-12.14.sql

I am on Mac OS X and don't have the sort -V option


You can probably sort by time using ls -lrt or some combination like that

r for reverse, t for time


Try using the sort utility:

ls | sort -n 


Not sure about Mac OS, but give this a try:

 LC_COLLATE=C ls -1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜