Skip to Content
プログラミング言語AWK 第2版
book

プログラミング言語AWK 第2版

by Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger, 千住 治郎
May 2024
Intermediate to advanced
276 pages
3h 51m
Japanese
O'Reilly Japan, Inc.
Content preview from プログラミング言語AWK 第2版

2章Awkの実践例

Awk は小規模ツールや個人用スクリプトの開発に適している。同じ処理の繰り返しを自動化したり、他の誰も目を向けないような、しかし当人にとっては重要な、特殊な計算などだ。

本章では例題を多く取り上げる。直接的には読者の役に立たないものもあるかもしれないが (一部の読者には役立つだろう)、自身で開発するプログラムやプログラミングに応用できる手法など、新たな視点が得られるだろう。

本章は、Awk が元々目的としていた単純な計算、および選択や変換、総和などの基本動作の例をふんだんに取り入れている。それ自体が興味深く、また有用なものばかりだ。Awk を紹介するものもあれば、プログラミングテクニックを示すものもある。一部の例は標準的な Unix ツールも併用する。Unix 環境では実用的な威力を発揮するだろう。

2.1個人用ツール

Awk はプログラム可能なツールとしても優れている。計算式を 1 コマンドにカプセル化し、個人用ツールとして手元に置いておける。本節では、著者陣が有用と考える小規模プログラムの例を挙げる。

BMI (体格指数)

BMI (Body mass index、体格指数) は肥満を測る指標として広く使用されている、次の計算式を用い、身長と体重から指標となる数値を求める方法だ。

bmi = weight / height2

BMI の値が 18 から 25 の範囲は「普通 /normal」と、25 から 30 までを「過体重 /overweight」と、30 以上を「肥満 /obese」と定義されてい†1。公式には単位にメートルとキログラムを用いるが、ここでの実装ではインチとポンドを用いる。すなわち、プログラムで単位を変換する必要がある。1 キログラムは 2.2 ポンド、1 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

プログラミングRust 第2版

プログラミングRust 第2版

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall, 中田 秀基
仕事ではじめる機械学習 第2版

仕事ではじめる機械学習 第2版

有賀 康顕, 中山 心太, 西林 孝
詳説 イーサネット 第2版

詳説 イーサネット 第2版

Charles E. Spurgeon, Joann Zimmerman, 三浦 史光, 豊沢 聡
Linuxカーネルプログラミング 第2版

Linuxカーネルプログラミング 第2版

Kaiwan N. Billimoria, 武内 覚, 大岩 尚宏

Publisher Resources

ISBN: 9784814400706Publisher Website