---

How to use sed to find and replace text in files in Linux / Unix shell

I am a new Linux user. I wanted to find the text called ‘foo’ and replaced to ‘bar’ in the file named ‘hosts.txt.’ How do I use the sed command to find and replace on Linux or UNIX-like system?

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis