Linux Sed命令复制替换两次

Linux Sed命令复制替换两次,linux,sed,terminal,Linux,Sed,Terminal,我有一个简单的文件,其中的内容存储在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 warr

我有一个简单的文件,其中的内容存储在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.