通过这一行,我总是在匹配之前得到 Standardinput
作为文件名。
有没有办法重写这一行以获取匹配项前面的真实文件名?
find . -name '*.doc' -exec wvText {} \; | grep -rH --color word
最佳答案
find . -name '*.doc' | xargs -d"\n" grep -rH --color word
啊,那不处理其中的 wvText
位。也许是这样的:
for doc in `find . -name '*.doc'`; do wvText "$doc" | grep -rH --color word | \
sed "s;^;$doc: ;"; done
关于bash - grep : how to put the filename before each match, 当文件来自管道时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7840785/