0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[CentOS/Ubuntu/Macに]ag(the silver searcher)をインストール

Last updated at Posted at 2020-11-18

この記事を書いた理由 :shinto_shrine:

ファイルの中身を検索できるコマンドと言えば『grep』ですが、そのgrepを高速化した『grab』や『ack』、『ag』等が登場し移行する人が出てきています。

今回はその中で特に早いと噂1agを、VirtualBox/Vagrantで仮想構築したCentOS8上にGitHubのドキュメントに沿って下記のコマンドでインストールしようとしました。しかし...

-- yumでも結果は同じ
$ sudo dnf update
$ sudo dnf install the_silver_searcher
-- 下記のエラーが出てインストール出来ない
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:04:22 ago on Wed Nov 18 17:23:56 2020.
No match for argument: the_silver_searcher
Error: Unable to find a match: the_silver_searcher

しかし上記のようにエラーが出てインストール出来なかったので上手く行く方法を下記していきます。
ついでにMacやUbuntuでも同じことをやっていきます。

各種OSにインストール :champagne:

CentOS8

  • バージョン確認
$ cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
  • インストール
-- README.mdのdependenciesに下記二つ記載あり
$ sudo dnf -y groupinstall "Development Tools"
$ sudo dnf -y install pcre-devel xz-devel zlib-devel
$ cd /usr/local/src
$ sudo git clone https://github.com/ggreer/the_silver_searcher.git
$ cd the_silver_searcher/
$ sudo ./build.sh
$ sudo make install
-- agが入っていることを確認
$ which ag
/usr/local/bin/ag

Ubuntu

  • バージョン確認
$ cat /etc/os-release
-- 一部省略
VERSION="20.04.1 LTS (Focal Fossa)"
  • インストール
$ apt update
$ sudo apt install silversearcher-ag
-- agが入っていることを確認
$ which ag
/usr/bin/ag

※Ubuntuは仮想環境ではなくLENOVO ideapad 330Sに直インスコしたのを使っています。

MacOS

  • バージョン確認
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.7
BuildVersion:   19H15
  • インストール
$ sudo brew install the_silver_searcher
-- agが入っていることを確認 
$ which ag
/usr/local/bin/ag

※Homebrewが未インストールならこのリンク先記事を参考にインストールしてください。

今後、時間を見つけてagの使い方やgrepとの比較について軽く記事を書く予定です。:rocket:
本日は以上です。

参考記事 :blue_book:

  1. 筆者の感覚値としても圧倒的に早いしgrepより速いackより3〜5倍高速との情報もある。ただこれに異議を唱える人もおり筆者も数値的な検証はしていないのでここで明言はできません。ごめんね。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?