Be introduced to thesed stream editor, which enables you to make bulk text modifications to strings and files.
It will almost definitely be fine for the examples we discuss here.
applies small text transformation using what is called a RegEx, or Regular Expression.
Regular expressions are complicated, and may be hard to read for beginners.
For the purpose of this article, we will stick with easy to understand and read regular expressions.
We thus transformed ‘Hello Cloud Savvy IT fans!’
to ‘Hello cloudsavvyit.com fans!’
by only changing a part of the text using the sed stream editor.
Let’s take a slightly more complex example.
Next we displayed the file contents using the
command.
We then transformed the contents of the file with the
tool directly.
To do so, we specified the ‘-i’ option to sed which edits file in-place.
The actual textual transformation instruction is the same as before.
And finally we specify the filename at the end of the command.
We then check the file contents and notice how our input has changed.
Note also how we have used different field/command option separators.
In the first example we used ‘|’ which is overall an easy-to-use, and fairly uncommon field separator.
You see how versatile sed can be.