[英]Sed command replicating substitution twice
我有一個簡單的文件,內容存儲在 temp.txt
Here I lay in the depths of hell waiting to be rescued by my charming warrior.
一旦我使用 sed 命令替換
sed -i "s/hell/HELL/p" ./temp.txt
這是我得到的結果
Here I lay in the depths of HELL waiting to be rescued by my charming warrior.
Here I lay in the depths of HELL waiting to be rescued by my charming warrior.
有什么建議么?
/p 標志復制該行。 因此,如果您只想替換該事件,請避免使用它。 所以命令將是:
sed -i "s/hell/HELL/" ./temp.txt
你的文件將是:
Here I lay in the depths of HELL waiting to be rescued by my charming warrior.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.