gpt4 book ai didi

linux - 如何回显文件名?

转载 作者:太空宇宙 更新时间:2023-11-04 12:32:30 25 4
gpt4 key购买 nike

我正在使用此命令搜索 .docx 内容:

unzip -p *.docx word/document.xml | sed -e 's/<[^>]\{1,\}>//g; s/[^[:print:]]\{1,\}//g' | grep $1

但我需要包含我搜索的单词的文件名。我该怎么做?

最佳答案

您可以通过for 循环遍历文件:

for file in *.docx; do
unzip -p "$file" word/document.xml | sed -e 's/<[^>]\{1,\}>//g; s/[^[:print:]]\{1,\}//g' | grep PATTERN && echo $file
done

&& echo $file 部分在 grep 找到模式时打印文件名。

关于linux - 如何回显文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42920437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com