Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 708 Bytes

sed.md

File metadata and controls

31 lines (20 loc) · 708 Bytes

sed (stream editor)

Use literal '-' in regex range expression

To include a hyphen ('-') in a range expression, it must be escaped and placed either at the start or end of the expression.

Strip ANSI color codes from text stream or files

To remove color escape sequences from files, such as in text files generated by logging colorized terminal stdout, use:

sed 's/\x1b\[[0-9;]*m//g'

Print all text after a regex match

To match all text after a particular pattern, use:

... | sed -n '/<regex</,$p'

Note that this will include the pattern-matched line itself in the output.

Remove all text between and including a pattern

sed -e '/pattern1/,/pattern2/d'