ms dos或cygwin下搜索docx文件的命令行工具
有没有一个命令行工具可以在ms dos或cygwin下搜索docx文件?
我尝试过 grep,它不能与 docx 一起使用,而可以与 txt 文件一起正常工作。
我知道我总是可以先将 docx 转换为 txt,然后使用 grep 进行搜索,但我想知道
是否有一个命令工具可以直接在命令行下搜索?
谢谢
Is there a command line tool that is able to search docx file under ms dos or cygwin ?
I have tried grep, it's not working with docx while working fine with txt file.
I know I could always convert the docx to txt 1st then search using grep, but I am wondering
is there a command tool that I can search directly under command line?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我写了一个小的 bash 脚本,它可以帮助您:
将其保存为 docfind.sh,您可以
从任何要扫描的文件夹中调用。
i wrote a small bash script, which would help you:
save it as docfind.sh and you can invoke
from any folder you want to scan.
经过尝试后,我发现最简单的方法是使用 Linux 实用程序将所有 docx 文件批量转换为 txt 文件,然后轻松地对这些 txt 文件执行 grep 操作。
After a trying out the stuff , I found the easiest way to do this is to use a linux utility to batch convert all docx files into txt files, then do grep with those txt files easily.
zgrep 可能适合你?它通常在 OpenOffice 文档中工作,并且都是包含 XML 的压缩档案:
我没有 .xdoc 文件来测试它,但理论上它应该工作......
zgrep might work for you? It usually works in OpenOffice documents, and both are compressed archives containing XML:
I have no .xdoc files to test this with, but in theory it should work...
您可以使用 zipgrep,它对 zip 存档(即 docx 文件)的所有文件调用 grep。
不过,您可能会对结果感到失望,因为它返回包含文本和 XML 标记的 XML 文件的原始内容。
You can use zipgrep, which calls grep on all files of a zip archive (which a docx file is).
You might be disappointed with the result, though, as it returns raw content of XML files containing both the text and XML tags.
像我这样的新手可能需要被告知,要使 .sh 脚本可以从任何目录执行,它需要具有 可执行属性集 并位于 /usr/bin 或 路径。
我能够在 Linux Mint 中设置 nemo 文件管理器,从任何文件夹的上下文菜单中打开终端 (信息在此)。
Newbies like me might need to be told that for the .sh script to be executable from any directory, it needs to have the executable property set and be located in /usr/bin or elsewhere in your Path.
I was able to set up the nemo file manager in Linux Mint to open a terminal from any folder's context menu (information here).