linux搜索word文档内容,在目录中搜索MS word文件以获取Linux中的特定内容
我有一個充滿MS word文件的目錄結構,我必須在目錄中搜索特定的字符串.到目前為止,我使用以下命令在目錄中搜索文件
find . -exec grep -li ‘search_string’ {} \;
find . -name ‘*’ -print | xargs grep ‘search_string’
但是,此搜索不適用于MS word文件.
是否可以在Linux中的MS word文件中進行字符串搜索?
解決方法:
我是一名翻譯,并且幾乎不知道腳本編寫,但我很生氣,因為grep無法掃描Word .doc文件,我研究了如何使這個小shell腳本使用catdoc和grep來搜索目錄.doc文件的給定輸入字符串.
您需要安裝catdocand docx2txt包
#!/bin/bash
echo -e "\n
Welcome to scandocs. This will search .doc AND .docx files in this directory for a given string. \n
Type in the text string you want to find... \n"
read response
find . -name "*.doc" |
while read i; do catdoc "$i" |
grep --color=auto -iH --label="$i" "$response"; done
find . -name "*.docx" |
while read i; do docx2txt < "$i" |
grep --color=auto -iH --label="$i" "$response"; done
歡迎所有改進和建議!
標簽:linux,unix,ms-word
來源: https://codeday.me/bug/20191006/1860465.html
總結
以上是生活随笔為你收集整理的linux搜索word文档内容,在目录中搜索MS word文件以获取Linux中的特定内容的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 转lua解释执行脚本流程
- 下一篇: mpvue 微信小程序 显示 转发按钮