String replacement is a frequently-used text-processing task. It can be done easily with regular expressions by matching the required text.
When we hear the term 'replace', every system admin will recall sed.
sed is the universal tool under UNIX-like systems to make replacements in text or in a file. Let's see how to do it.
sed primer recipe contains most of the usages of
sed. You can replace a string or pattern as follows:
$ sed 's/PATTERN/replace_text/g' filename
$ stdin | sed 's/PATTERN/replace_text/g'
We can also use double quote (") instead of single quote ('). When double quote (") is used, we can specify variables inside the
sed pattern and replacement strings. For ...