[英]Why does Perl delete file content when used with find?
任何人都可以看到為什么Perl與find
一起使用時會刪除所有文件內容嗎?
echo stning >> test.tex
echo stning >> test.tex
find . -type f -name \*.tex -print0 | xargs -0 perl -i -ne 's/stning/sætning/g'
cat test.tex
最后一個命令不返回任何內容,這就是問題所在。
您可以使用sed本身來實現結果。 正如您需要的是內聯替換。
find . -type f -name \*.tex -print0 | xargs -0 sed -i 's/stning/sætning/g'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.