Notes:
sed(1) is a stream line editor that reads input from piped data or named files. Such input is processed as follows:
- Read a record into a buffer known as a pattern space. Then:
- Compares the line address in the pattern space to editing commands stored in memory.
- If it’s the correct line number, then it checks for a pattern match.
- If there’s a match, then the edit takes place, otherwise, the line is left unchanged.
- In either case, the pattern is copied to standard output (unless the -n option is specified). This process is different from awk’s functionality.
- Remove the pattern space
- Repeat steps one through six until there is no more data to read.
Understanding how a command functions is very useful. This can help individuals which commands are best suited for specific tasks; allowing one to write more efficient programs.