" find -type f -iname' * .txt' | xargs -I {} echo""> {}"不起作用

时间:2017-03-09 08:59:31

标签: linux bash

我正在使用linux bash。现在我想清除所有 .txt文件的内容。但是,这个命令" find -type f -iname' .txt' | xargs -I {} echo""> {}"好像不行。有什么建议?关于更好解决方案的任何想法?

1 个答案:

答案 0 :(得分:1)

我将echo替换为truncate以清除文件并使用查找-exec而不是管道xargs

find . -type f -name "*.txt" -exec truncate -s 0 {} \;