小编use*_*548的帖子

如何使用bash脚本对与字符​​串+数字组合的字符串进行排序?

这是我要排序的数据。但是sort将数字处理为字符串,数据没有按我预期的那样排序。

/home/files/profile1
/home/files/profile10
/home/files/profile11
/home/files/profile12
/home/files/profile14
/home/files/profile15
/home/files/profile16
/home/files/profile2
/home /files/profile3
/home/files/profile4
/home/files/profile5
/home/files/profile6
/home/files/profile7
/home/files/profile8
/home/files/profile9

我想把这个排序,

/home/files/profile1
/home/files/profile2
/home/files/profile3
/home/files/profile4
/home/files/profile5
/home/files/profile6
/home/files/profile7
/home/files/profile8
/home /files/profile9
/home/files/profile10
/home/files/profile11
/home/files/profile12
/home/files/profile14
/home/files/profile15
/home/files/profile16

bash脚本有什么好方法吗?我不能在这里使用 ruby​​ 或 python 脚本。

bash shell-script text-processing sort

27
推荐指数
3
解决办法
3万
查看次数

标签 统计

bash ×1

shell-script ×1

sort ×1

text-processing ×1