sed

sed is a stream editor. This tool allows you to change the contents of a file, without opening the file, but its power goes far beyond that.

Basic syntax:
sed -i 'backup_extension' 'command' filename

For example, if you had a file test.txt:

Hello World!
This is line 2!

In the first example, we will change the word ‘World’ to ‘User’:

sed -i '.bak' 's/World/User/' test.txt

This will give us the test.txt file containing Hello User!, and a backup file test.txt.bak.