How does sed work for stream editing?

Answer

sed (stream editor) applies editing commands to each line of input. The most common usage is substitution: sed 's/old/new/g' file replaces all occurrences of "old" with "new" (g = global; without it, only the first occurrence per line is replaced). sed -i 's/foo/bar/g' file.txt edits the file in-place. sed -n '10,20p' file prints only lines 10 through 20. sed '/^#/d' config deletes comment lines. sed 's/^/ /' file indents every line. sed supports full regular expressions and multiple commands with -e. It is indispensable for automated text transformation in CI/CD pipelines and configuration management scripts.