rgpipe
1.0.0
rgpipe是一个bash/sh脚本,也是与ripgrep一起使用的别名,以搜索无数不友好的文件类型。将其与RIPGREP的-PRE命令一起使用,该命令允许RIPGREP在搜索之前选择性处理文件。
最基本的用法是将rgpipe指向某些文件,它将尝试将所述文件的内容打印到STDOUT。
rgpipe MyFancyExcelFile.xlsx
涉及的用法越多,是在Ripgrep面前的过滤器,以系统地尝试浏览各种非文本文件的内容,就像您的文本文件一样。基本的咒语看起来像:
rg --pre-glob '*.{xlsx,pptx,docx,pdf}' --pre rgpipe "$YourSearchTermHere"
我写了一个关于如何在这里使用它的长篇大论
这种要点才有用,因为Burntsushi在此黑客新闻评论中说明了rg --pre-glob工作方式。
这有助于解决:
unzip和sedstringsunzip和sedpdftottextw3m lynx和朋友也有效。不是100%必需的。unzip和w3m for epub7zip和w3m ubuntu想要: sudo apt install poppler-utils p7zip w3m unzip
术语想要: pkg install poppler p7zip w3m
假设rgpipe在路径中,如果不是
rg --pre rgpipe YourSearchTermHere上面使用rgpipe,即使不需要它,速度很慢,ripgrep可以选择性地使用-pre-glob
rg --pre-glob ' *.{xlsx,pptx,docx,pdf} ' --pre rgpipe YourSearchTermHere一个更彻底的预遍:
rg --pre-glob ' *.{pdf,xl[tas][bxm],xl[wsrta],do[ct],do[ct][xm],p[po]t[xm],p[op]t,html,htm,xhtm,xhtml,epub,chm,od[stp]} ' --pre rgpipe YourSearchTermHere别名,因为那是很多打字
alias rgg= " rg -i -z --max-columns-preview --max-columns 500 --hidden --no-ignore --pre-glob
'*.{pdf,xl[tas][bxm],xl[wsrta],do[ct],do[ct][xm],p[po]t[xm],p[op]t,html,htm,xhtm,xhtml,epub,chm,od[stp]}' --pre rgpipe "步骤1:使用rgpipe制作文本边防文件
find-rgpipe-type () {
find ` pwd ` -type f -iname " *. $1 " -exec sh -c ' for f; do rgpipe "$f" > "${f%.*}.txt"; done ' _ {} +
}
# or get fancy with xargs for multithreaded goodness
find-rgpipe-type-xargs () {
find " $( pwd ) " -type f -iname " *. $1 " -print0 | xargs -0 -P0 -n 1 -I {} sh -c ' rgpipe "{}" > "{}.txt" '
}
使用上面定义的函数,在当前目录下为所有具有PDF扩展的文件进行文本侧码。
find-rgpipe-type pdf步骤2:使用RIPGREP搜索这些文件
rg YourSearchTermHere1-这篇黑客新闻评论
2-预处理脚本是我添加了更多文件类型的模板
3-午夜指挥官在这个主题上有很棒的脚本
4-少管当然
5 -RGA是一种基于生锈的工具做类似的事情
rgpipe ,因为这个想法类似于小管子。