如何从 BASH 脚本强制将查询输出到文件中?
我试过了
> file.txt
| >> file.txt
还有一些
我一直在吐出语法错误,或者根本无法工作。
find fixed/pdf/ -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "Ascend"' \; | 2>&1 dump.txt
最佳答案
您可以使用:
find fixed/pdf/ -name '*.pdf' -exec sh -c 'pdftotext "$1" - |
grep --with-filename --label="$1" --color "Ascend"' - '{}' \; > dump.txt 2>&1
将 stdout 和 stderr 重定向到您的文件 dump.txt
。
关于linux - bash,如何将标准输出到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32681911/