我正在使用linux bash。现在我想清除所有 .txt文件的内容。但是,这个命令" find -type f -iname' .txt' | xargs -I {} echo""> {}"好像不行。有什么建议?关于更好解决方案的任何想法?
答案 0 :(得分:1)
我将echo
替换为truncate
以清除文件并使用查找-exec
而不是管道xargs
:
find . -type f -name "*.txt" -exec truncate -s 0 {} \;