免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1781 | 回复: 1
打印 上一主题 下一主题

awk脚本输出顺序问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-14 09:53 |只看该作者 |倒序浏览
% cat datafile
northwest     NW     Joel Craig       3.0     .98     3      4
western       WE     Sharon Kelly     5.3     .97     5     23
southwest     SW     Chris Foster     2.7     .8      2     18
southern      SO     May Chin         5.1     .95     4     15
southeast     SE     Derek Johnson    4.0     .7      4     17
eastern       EA     Susan Beal       4.4     .84     5     20
northeast     NE     TJ Nichols       5.1     .94     3     13
north         NO     Val Shultz       4.5     .89     5      9
central       CT     Sheri Watson     5.7     .94     5     13



% cat awk.sc6
# Awk and the special for loop
{region[$1]++}  # The index is the first field of each record

END{for(item in region){        
        print region[item], item
     }
}

% awk -f awk.sc6 datafile

1 central
1 northwest
1 western
1 southeast
1 north
1 southern
1 northeast
1 southwest
1 eastern

执行awk脚本后,输出第一排是central,第二个变成northwest,请教大家,从上到下,按什么顺序输出的,还是随机输出的?

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
2 [报告]
发表于 2008-06-14 10:30 |只看该作者
这个顺序是awk定的,对使用来说没用,你可以认为这是随机的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP