【发布时间】:2014-03-27 20:23:03
【问题描述】:
我有一个使用 AWK 脚本的作业,但我无法理解为什么会遇到这个问题。基本上我只想在脚本末尾输出一行简单的输出,但由于某种原因它不起作用。
print "Listed are their names (sorted by last names) and phone numbers:"
for(i = 1; i < x; i++)\
{print " "topNames[i]"--"topPhones[i] | "sort -k 2";}
print " Thanks to all of you for your continued support!!"
正在输出:
Listed are their names (sorted by last names) and phone numbers:
Thanks to all of you for your continued support!!
John Goldenrod--(916) 348-4278
Mike Harrington--(510) 548-1278
Archie McNichol--(206) 548-1348
Guy Quigley--(916) 343-6410
Dan Savage--(406) 298-7744
Tom Savage--(408) 926-3456
Elizabeth Stachelin--(916) 440-1763
虽然我希望它是:
Listed are their names (sorted by last names) and phone numbers:
John Goldenrod--(916) 348-4278
Mike Harrington--(510) 548-1278
Archie McNichol--(206) 548-1348
Guy Quigley--(916) 343-6410
Dan Savage--(406) 298-7744
Tom Savage--(408) 926-3456
Elizabeth Stachelin--(916) 440-1763
Thanks to all of you for your continued support!!
我真的很困惑为什么它没有按照我想要的顺序输出。
另外附注。什么是 AWK 脚本的好的编程风格(cmets 等)?我习惯使用 C++,所以我不确定在哪里放置缩进以及如何对齐我的 cmets。
任何帮助将不胜感激。
【问题讨论】: