0

I am trying to use sed to replace a string with another one. I used the below command and it worked just fine up until I ran cat index.html and it went back to the old string. Can someone help, please?

<h1>
Hello World
</h1>
<p>This is out first WebDev study</p>
</body>
</html>
$ sed 's/Hello World/About Us/' index.html
<!DOCTYPE>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>
About Us
</h1>
<p>This is out first WebDav study</p>
</body>
</html>
$ cat index.html
<!DOCTYPE>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>
Hello World
</h1>
<p>This is out first WebDav study</p>
</body>
</html>
Murad M
  • 13

1 Answers1

2

From the man page:

-i[SUFFIX], --in-place[=SUFFIX]
     edit files in place (makes backup if SUFFIX is supplied)

So, in your case you just need to add the flag:

sed -i 's/Hello World/About Us/' index.html
user1794469
  • 4,067
  • 1
  • 26
  • 42