Stream Editor - Workflow
If you want to become an expert in SED, then you should know about SED internal. Read, execute, and display is a simple workflow for SED.
Read:Read a line from the input stream and stores in its internal buffer.
Execute:Execute SED command on a line.
Display:Display result on output stream.
Note:The above process repeats until the file is exhausted.
Let us create a text file lfc.txt to include a quote by Letsfindcourse.
$ vi lfc.txt Questioning is the beginning of intelligence. - Letsfindcourse
To understand the workflow of Stream Editor let us display the contents of the file lfc.txt using SED.
$ sed '' lfc.txt
It will produce the following result.
Questioning is the beginning of intelligence.
There is a pair of single quotes preceding the input file name which implies the SED command. First SED reads a line from the text file and inserts it into the pattern buffer, then the SED command is applied to the pattern buffer. There is no such SED command so no operation is performed on the pattern buffer. Typically it prints the contents of the pattern buffer at standard output.
Few points to note:
1. Pattern buffer is a private, in-memory, volatile storage area used by the SED.
2. If address range is not provided by default, then SED operates on each line.
3. If no input files are provided, then SED accepts input from the standard input stream.
4. Initially both pattern and hold buffers are empty.