Use sed to apply quick, repeatable edits directly to files from the shell. 16.11.2025 | reading time: 2 min Want to change dozens of config files without opening an editor for each one? sed is the stream editor that lets you perform substitutions and edits directly on files from the shell, making repetitive changes fast and scriptable. Replace a service name Follow a concrete session to see sed in action: create a small file, show its content, perform an inline substitution and show the result; this demonstrates that sed changes the file on disk without launching an editor. ```bash printf "server1:10.0.0.1\nserver2:10.0.0.2\noldservice:10.0.0.3\n" > services.txt cat services.txt # server1:10.0.0.1\nserver2:10.0.0.2\noldservice:10.0.0.3 sed -i 's/oldservice/newservice/' services.txt cat services.txt # server1:10.0.0.1\nserver2:10.0.0.2\nnewservice:10.0.0.3 ``` Safer workflows and regex power Never run large in-place edits blind: test your expression without `-i` first, then use `-i.bak` to keep a backup; on Linux you may use `-r` for extended regex or `-E` on BSD/macOS, chain multiple edits with `-e` or semicolons, target ranges like `5,10s/.../.../`, switch delimiters with `s|old|new|` to avoid heavy escaping, and combine with `find -exec` or `xargs -0` for bulk changes. When sed is not enough sed excels at stream substitutions and simple scripts, but for column-aware processing, more complex parsing or in-place edits with richer logic use tools like awk or perl, or use sponge to safely read-and-write streams when necessary. Next steps Practice with real files, build small scripts that test substitutions first, and incorporate backups into automation; if he wants a structured path to mastering Linux tools consider certifications like CompTIA Linux+ or LPIC-1 and prepare intensively with courses at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting filesystem troubleshooting