Date: 3/26/2014 |
|
|
String editor, sed, is used for editing lines in a file or a stream; output is going to the standard output and can be re-directed to a new file. Syntax:
Delete lines from 3 through 5 in file list.txt:
Delete lines that contain "O" at the beginning of the line:
Translate capital C,R,O into small c,r,o:
Delete ampty lines:
Replace string Oop with Wee for the first occurence on a line
Remove ss string (replace with empty entry)for the first occurence on a line:
Remove ss string for all occurences on a line:
Substitute a single space for any number of spaces wherever they occur on the line:
Substitute underscore for any number of spaces wherever they occur on the line:
More examples: Useful one-line scripts for sed Recommended tutorial: The GNU sed stream editor |
|