Kabads

Using sed

sed is a quick command line utility to change text within a file, or input stream. Typically, it is used within a pipe situation

(i.e. using the character | on the command line). If you are not familiar with that command, you will need to research that before continuing.

A simple use of sed is to replace characters in a stream or file. This is done using regular expressions. This will help you search for a set of characters and then replace them with the alternative. This is done using the s command.

Replacing text with sed

Probably, the most common use of sed is to replace text. This is achieved through by:

sed s/textToFind/newText filename

This will search for the first occurance on each line. If that search string is found twice on a line, the second instance will be ignored. To get around this you need to add a global flag to the end of the command as such:

sed s/textToFind/newText/g filename