CentOS 7 に最新の awk (gawk) をインストールする

GNU awk (gawk) はまだまだ進化しているようで、本稿執筆時点ではメジャーバージョンが v5 になっている。さすがにメジャーバージョンが変わると慎重になるが、v4 系に後から追加されたオプション引数を試してみたく、v4.2.1 をインストールしてみた。

試したのは CentOS 7 系だが、Linux 系ならどれでも同じだと思われ。

gawk の各バージョンのソースコードは、以下の URL から取得できる。

今回は v4.2.1 をインストールしたいので、以下の圧縮ファイルを取得すれば良さそうだ。

以下、root ユーザで作業している。

# ソース置き場に移動する
cd /usr/local/src

# 圧縮ファイルをダウンロードする
wget http://ftp.gnu.org/gnu/gawk/gawk-4.2.1.tar.gz
tar -xpvzf gawk-4.2.1.tar.gz
cd gawk-4.2.1/

# インストールする
./configure
make
make install

# バージョン確認
$ gawk --version
GNU Awk 4.2.1, API: 2.0
Copyright (C) 1989, 1991-2018 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

コレだけ。簡単。