Search and replace of text in a file using a script

I have a script and in this srcipt I need to replace in another text file a servername 'localhost:3000' with another servername.

What is the simplest way to do this with Linux?

I know the path of the file in my script and  there is only one file I need to change, so I am looking for a simple command. That should suffice.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

pzurowskiConnect With a Mentor Commented:
or maybe this one:
sed -i 's/localhost:3000/new_host:999/g' /path/to/a/file

Open in new window

$vi file_name
the  click the button Esc 2 times then type :wq then [Return]
This will replace localhost:3000 in the initial fo that in a new file make:
#cp file1 file2
#vi file2
ostraatenAuthor Commented:
Exactly what I was looking for, thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.