0

我想用linux shell 中的find 命令将一些文本回显到所有文件匹配中。我试过这个” find . -type f -name "file*.txt" -exec echo "some text" > - '{}' ';'但这不起作用。无论如何我可以解决这个问题吗?

4

1 回答 1

1

您的命令不起作用,因为它是由类似or>的 shell 解释的。开始使用时。没有外壳可以解释为重定向。shbashfind -exec echoecho>

请注意,> 过度写入文件。你可能想追加. 用于>>这样做。

find . -type f -name 'file*.txt' -exec sh -c 'echo "some text" >> "$0"' {} \;
于 2020-05-16T09:51:00.490 回答