sed is a stream editor command available on Unix-compatible systems.
sed is quite a powerful tool, but the learning curve is also high comparing to other similar tools such as
Almost every time I want to do something with
sed, I need to look it up and search for some examples.
So, I decided to compile a concise tutorial for
sed that covers the most common use-cases.
sed, you usually specify a few options and a script and feed it with an input file.
sed <options> <script> <input_file>
Here are some options for
sed command that you most likely need to know about them.
|Edits the input file in-place.|
|Specifies the scripts for editing.|
|Suppresses printing each line of input.|
Here are some common commands that you may use in
|Global applies a command to every line of input.|
|Prints the matching patterns to standard output.|
|Deletes the matching patterns from output or input file.|
|Replaces a regexp instance with the replacement.|
|Shows a single line by line number.|
|Shows all lines except one line number.|
|Shows multiple lines by line numbers.|
|Shows multiple lines by a range.|
|Shows all lines except a range of lines.|
|Shows all lines after a line number.|
|Shows all lines before a line number.|
|Deletes a particular line in-place.|
|Deletes a range of lines in-place.|
|Deletes all lines matching |
|Deletes all lines after a line matching |
|Replaces all occurrences of |