ripgrep

ripgrep for windows下载

Install

dnf install snapd
systemctl enable snapd
systemctl start snapd

ln -s /var/lib/snapd/snap
snap install ripgrep --classic

#snap install certbot --classic
选项:
–help:显示帮助信息。
-i:忽略大小写。
-w:匹配整个单词。
-v: 反向匹配(不包含模式)
-e: 指定正则表达式
-z: 搜索压缩文件
-l:仅显示匹配文件名。
-t:指定文件类型。
-g:文件路径匹配模式。
-P: 使用 PCRE2 引擎

rg --pcre2-version

-j 1 : 使用一个线程

rg --type-list
rg --files

默认是正则式
rg 'main\(\)' -t c                  查找main()
rg 'hexo\w*' README.md
rg -v 'hexo' README.md              反向
rg 'TODO|FIXME' -t py -t java
rg -w 'github.com' ./
rg -w 'github.com' ./ -l            只搜索过文件名
rg cache . -tphp
rg cache . -Tphp
rg 'function bind' --type js
rg 'function bind' -g '*.js'
rg 'function bind' -g '*.[js,css}'
rg -e 'tou.*ist' ./                 正则表达式搜索
rg 'hexo\w*' README.md -C2          上下两行的内容
rg 'ERST' -z dmesg.1.gz             压缩文件
rg "EXT4-fs \(sda3\)" /var/log/syslog -B 1 -A 2  注:Before 1 After 2
先安装 RUST
curl https://sh.rustup.rs -sSf | sh

用 RUST 安装 ripgrep
git clone https://github.com/BurntSushi/ripgrep
cd ripgrep
cargo build --release
cp ./target/release/rg /usr/local/bin/