使用我越來越有以下sed的:-i可能無法與標準輸入#錯誤
find . -name "*" -type f | xargs grep -l "xyz" | sed -i '' 's/'${line}'/'${rep}'/g'
sed: -i may not be used with stdin
什麼出了錯錯誤?
使用我越來越有以下sed的:-i可能無法與標準輸入#錯誤
find . -name "*" -type f | xargs grep -l "xyz" | sed -i '' 's/'${line}'/'${rep}'/g'
sed: -i may not be used with stdin
什麼出了錯錯誤?
Asuming,你想的sed的東西只有在包含XYZ的文件,你將不得不再次xargs的
find . -name "*" -type f | xargs grep -l "xyz" |xargs sed -i "s/'${line}'/'${rep}'/g"
-i
用於內聯文件編輯,您只需在stdin中將find命令的輸出管道輸入到sed
,因此會顯示錯誤。
試試這個find command
代替:
find . -name "*" -type f -exec sed -i '' "s/${line}/${rep}/g" '{}' \;
PS:-name "*"
也可以在這裏跳過。
當我們使用find命令,我們不能將輸出與連接管道(|)。所以你可以使用-exec和find命令來執行更多的命令。