当前位置: 技术问答>linux和unix
一个关于sort排序的问题,麻烦会的帮帮忙
来源: 互联网 发布时间:2016-05-15
本文导语: commission_withhold_2,0,0.14,0.00,7,49541,0,24543587 commission_withhold_3,0,0.28,0.00,7,49541,0,24543588 commission_withhold_1,0,0.14,0.00,1,49531,0,24543572 commission_withhold_4,0,0.14,0.00,1,49531,0,24543589 commission_withhold_5,0,0.14,0.00,2,49521,0,24543590 commission_withhold_...
commission_withhold_2,0,0.14,0.00,7,49541,0,24543587
commission_withhold_3,0,0.28,0.00,7,49541,0,24543588
commission_withhold_1,0,0.14,0.00,1,49531,0,24543572
commission_withhold_4,0,0.14,0.00,1,49531,0,24543589
commission_withhold_5,0,0.14,0.00,2,49521,0,24543590
commission_withhold_6,0,0.14,0.00,1,49531,0,24543595
commission_withhold_7,0,0.14,0.00,3,49465,0,24543598
commission_withhold_8,0,0.14,0.00,1,49531,0,24543591
commission_withhold_9,0,0.14,0.00,1,49531,0,24543551
commission_withhold_10,0,0.14,0.00,1,49531,0,24543558
commission_withhold_11,0,0.14,0.00,1,49531,0,24543579
以上内容用sort排序 排序顺序按第一个(,)前边的数字排序。
commission_withhold_3,0,0.28,0.00,7,49541,0,24543588
commission_withhold_1,0,0.14,0.00,1,49531,0,24543572
commission_withhold_4,0,0.14,0.00,1,49531,0,24543589
commission_withhold_5,0,0.14,0.00,2,49521,0,24543590
commission_withhold_6,0,0.14,0.00,1,49531,0,24543595
commission_withhold_7,0,0.14,0.00,3,49465,0,24543598
commission_withhold_8,0,0.14,0.00,1,49531,0,24543591
commission_withhold_9,0,0.14,0.00,1,49531,0,24543551
commission_withhold_10,0,0.14,0.00,1,49531,0,24543558
commission_withhold_11,0,0.14,0.00,1,49531,0,24543579
以上内容用sort排序 排序顺序按第一个(,)前边的数字排序。
|
给一个比较傻的方法。
假设当前目录test文件中保存了楼主的数据,使用下面的语句可以实现排序
cat test | awk -F'[_]' '{print $3}'|sort -g| awk '{printf("commission_withhold_%sn",$0);}'
输出结果为:
commission_withhold_1,0,0.14,0.00,1,49531,0,24543572
commission_withhold_2,0,0.14,0.00,7,49541,0,24543587
commission_withhold_3,0,0.28,0.00,7,49541,0,24543588
commission_withhold_4,0,0.14,0.00,1,49531,0,24543589
commission_withhold_5,0,0.14,0.00,2,49521,0,24543590
commission_withhold_6,0,0.14,0.00,1,49531,0,24543595
commission_withhold_7,0,0.14,0.00,3,49465,0,24543598
commission_withhold_8,0,0.14,0.00,1,49531,0,24543591
commission_withhold_9,0,0.14,0.00,1,49531,0,24543551
commission_withhold_10,0,0.14,0.00,1,49531,0,24543558
commission_withhold_11,0,0.14,0.00,1,49531,0,24543579
假设当前目录test文件中保存了楼主的数据,使用下面的语句可以实现排序
cat test | awk -F'[_]' '{print $3}'|sort -g| awk '{printf("commission_withhold_%sn",$0);}'
输出结果为:
commission_withhold_1,0,0.14,0.00,1,49531,0,24543572
commission_withhold_2,0,0.14,0.00,7,49541,0,24543587
commission_withhold_3,0,0.28,0.00,7,49541,0,24543588
commission_withhold_4,0,0.14,0.00,1,49531,0,24543589
commission_withhold_5,0,0.14,0.00,2,49521,0,24543590
commission_withhold_6,0,0.14,0.00,1,49531,0,24543595
commission_withhold_7,0,0.14,0.00,3,49465,0,24543598
commission_withhold_8,0,0.14,0.00,1,49531,0,24543591
commission_withhold_9,0,0.14,0.00,1,49531,0,24543551
commission_withhold_10,0,0.14,0.00,1,49531,0,24543558
commission_withhold_11,0,0.14,0.00,1,49531,0,24543579
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。