Working with sed
In this section, we will learn about the sed
command, the powerful stream editor. We will give you a brief introduction on how sed
works and we'll be showing you the substitution mode for automatically replacing text and files, which is one of the most important modes available. Next, we will learn about the sed
command. Let's first examine its syntax:
sed [OPTION] 'pattern rule' FILE
sed
stands for stream editor and this command can edit files automatically without any user interaction. It processes input files on a line-by-line basis. Oftentimes, sed
is used in shell scripts to transform any command's output to a desired form for further processing. Most everyday use cases for sed
follow a similar pattern, which, in its most simple form, is first used with a regular expression or other pattern to define which lines to change in an input file or stream, and then provide a rule on how to change or transform the matched line. Similar to the grep
command, always use single quotes...