Use sed to edit and transform text streams quickly and reliably from the shell. 30.04.2026 | reading time: 2 min Sed is a stream editor that reads text, applies scripted transformations and writes the result without opening an interactive editor; it is ideal for automated, repeatable edits in pipelines and scripts. Replace headers in a log Create a small log and change ERROR: headers to WARN: with sed:\n```bash\ncat <<'EOF' > logfile.txt\nERROR: Disk full on server1\nINFO: Backup completed\nERROR: Network timeout on server2\nEOF\n\nsed 's/^ERROR:/WARN:/' logfile.txt\n```\nThis prints:\n```text\nWARN: Disk full on server1\nINFO: Backup completed\nWARN: Network timeout on server2\n``` Power under the hood Use `-i` for in-place edits but add a backup suffix to be safe, use `-n` with `p` to suppress automatic printing, `-E` for extended regex, `-e` to chain commands and `-f` to load a script file; address ranges like `1,5` or `/start/,/end/` and capture groups with `\1` let you do targeted, complex edits. When to reach for other tools Sed excels at line-oriented, stream edits; reach for `awk` when you need field-aware processing, `perl` or `python` for very complex transformations, and `grep` when you only need selection rather than modification. Next steps Practice on small files, build sed scripts, and combine sed with other commands in pipelines to automate text work; for broader Linux mastery consider certifications like CompTIA Linux+ or LPIC-1 and prepare intensively with bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting