0

有一个名为 list.lst 的文件,我记下了它的内容。我需要编写一个 awk 脚本,它会在文件 list.lst 中生成一份报告,其中包含所有董事的姓名、部门名称和薪水。

该脚本可以执行为:awk –f director.awk list.lst

==================================================== =========

创建一个名为 marketing.awk 的 awk 脚本,它显示营销部门所有员工的姓名、职位和薪水。该脚本可以执行为:./marketing.awk list.lst

22233:charles harris     :g.m.    :sales         :12/12/52: 90000.00

29876:bill johnson      :director:production    :03/12/50:130000.00

25678:robert dylan      :d.g.m   :marketing     :04/19/43: 85000.00

22365:john woodcock     :director:personnel     :05/11/47:127000.00

25423:barry wood        :chairman:admin         :08/30/56:160000.00

21006:gordon lightfoot  :director:sales         :09/03/38:140000.00

26213:michael lennon    :g.m.    :accounts      :06/05/62:105000.00

24290:neil o'bryan      :executive:production   :09/07/50: 65000.00

22476:jackie woodhouse  :manager :sales         :05/01/59:110000.00

21265:p.j. wodehouse    :manager :accounts      :02/03/55: 97000.00

26521:derryk o'brien    :d.g.m   :accounts      :12/12/55: 85000.00

22312:bill wilcocks     :director:marketing     :09/26/45:125000.00

23564:ronie trueman     :executive:personnel    :07/06/47: 75000.00

22345:james wilcox      :g.m.    :marketing     :03/12/45:110000.00

20110:julie truman      :g.m.    :marketing     :12/31/40: 95000.00

20117:john trucman      :g.m.    :accounts      :12/25/41:110000.00

20123:frank -adams      :g.m.    :accounts      :09/25/48:110000.00

20129:Robin love        :director:sales         :10/01/08:120000.00
4

2 回答 2

3
awk -F: '$4 ~ /marketing/ {print $2, $3, $6}' list.lst
于 2012-10-03T12:42:06.887 回答
2

营销.awk

#!/usr/bin/awk -f
{
if($4~/marketing/)
{
print $2,$3,$6;
}
}
于 2012-10-03T13:16:45.423 回答