3���ܤ� �� 15�� �ۤ���褦�� �Ԥ� �ɤ߹��� ���Ӥˡ� ����ޤǤ� emp �� �ͤ� �ҤȤ� ���䤷�� ���ޤ��� ���� �Ȥ��� ���Ѥ���� awk �� �ѿ��ϡ� �ǽ�� �� 0 ���� �Ϥޤ�ޤ��� �������äơ� emp �� ��������� ɬ�פ� ����ޤ���
$3 > 15 { emp = emp + 1 } END { print emp, "employees worked more than 15 hours." }
��� awk �ץ������� m15.awk �Ȥ���̾���Ǻ������Ƥ������ʲ��Τ褦�˼¹Ԥ��ޤ����ʲ���Ʊ�ͤ� awk �ץ������ե�����κ����ȼ¹Ԥ��������Ʋ�������
sw%99 awk -f m15.awk emp.dat 3 employees worked more than 15 hours.
�Ȥ��� �ץ������ϡ� �¶�� ��פ� pay �� �û����� �����ޤ����顢 �Ǹ�ˡ� ���Ȱ��� ���� ����¶⡢ ʿ���¶�� ɽ������ ���Ȥ� �ʤ�ޤ��� ��ĤΥ�����������ʣ����̿��(��)��Ȥ��� ; (���ߥ�����)�� ���ڤ�ޤ������ print ����Ǥ�ɬ������ɬ�פǤϤ���ޤ��� �����Ȥ�������Ƥ����������褤�Ǥ��礦��
{ pay = pay + $2 * $3 } END { print NR, "employees"; print "total pay is",pay; print "average pay is",pay/NR; }
$2 > max { max = $2; who = $1 } END { print "Highest hourly rate:", max, "for", who }
{ names = names $1 " " } END { print names }
{ last = $0 } END { print last }
BEGIN { print "*** Employee Statistics ***" } $3 > 15 { emp = emp + 1 } { pay = pay + $2 * $3 } $2 > max { max = $2; who = $1 } { names = names $1 " " } { last = $0 } END { print "Employee list:", names; print NR, "employees"; print emp, "employees worked more than 15 hours." ; print "total pay is",pay; print "average pay is",pay/NR; print "Highest hourly rate:", max, "for", who ; print "Who was the last:",last; }
�����ƥ��ͭ�Υ桼��(root �� lp �ʤ����λŻ���褦�ˤʤäƤ��ޤ�) �� /etc/passwd ���������Ƥ��ޤ��� ���Υե�����Ǥ� �ƹ��ܤ� �� �� ���ڤ��� ���ޤ����顢
�Ȥ���С� root ����� ��̾�� �ФƤ��ޤ��� �ͥåȥ�������ƥ� NIS+ ����Ͽ���줿�桼���ξ����̤Υ��ޥ�ɤ� �桼������Υꥹ�Ȥ�ɽ�����뤳�Ȥ��Ǥ��ޤ��� ��â���� awk �� �Ȥ�ʤ��Ƥ⡢ finger ���ޥ�ɤ� �Ȥ��� ��̾�� ����¾�� ���� ɽ������ޤ�����
sw99% awk -F: '$1 == "root" {print $5}' /etc/passwd
�ʾ�Τۤ��ˤ⡢ awk �� �Ȥ߹��� �ؿ��䡢 if-elseʸ�� whileʸ�� forʸ
�ʤɤ� �Ȥä� ʣ���� ���� �ץ����������� �����ʤ� ���Ȥ� �Ǥ��ޤ���
������ �ܺ٤� �Ĥ��Ƥϡ� C����� �ؤ�� ��� ���ͽ� �֥ץ�����ߥ���AWK��
�����ۡ� �����˥ϥ� �磻��С��������� Ω�� �ʥȥåѥ� 3,400�ߡ�
�� �ɤळ�Ȥ� ����ޤ���
��������
awk ��Ȥä��������⤢��ޤ���