1、运行环境
系统:centos7
内核版本: Linux localhost 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
2、安装ag工具
2.1 下载源码
wget https://github.com/ggreer/the_silver_searcher/archive/master.zip
2.2 安装需要的工具包
yum -y install pcre-devel xz-devel zlib-devel
2.3 解压代码安装工具
解压代码,进入the_silver_searcher-master执行./build.sh进行编译,编译之后执行sudo -s make install 进行安装
[test@localhost ~]$ unzip master.zip
[test@localhost ~]$ cd the_silver_searcher-master/
[ test@localhost the_silver_searcher-master]$ ./build.sh
//执行安装
[ltj@localhost the_silver_searcher-master]$ sudo -s make install
需要注意的是如果不指定安装路径默认ag工具是安装到/usr/local/bin目录下。如果这时候系统中环境变量没有,会出现找不到情况。需要把/usr/local/bin添加到环境变量中。
[test@localhost ~]$ export
declare -x PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:
3、效果
使用ag -i + 查找的字符串就可以查询了。