The most useful and complete sed tutorial


Stream Editor, sed

pattern matching, delimiters, deletion, ranges, grouping, all explained!

http://www.grymoire.com/Unix/Sed.html

stream

And here’s a stream of one liners.

File Spacing

# double space a file

# double space a file which already has blank lines in it. Output file should contain no more than one blank line between lines of text.

# triple space a file

# undo double-spacing (assumes even-numbered lines are always blank)

# insert a blank line above every line which matches “regex”

# insert a blank line below every line which matches “regex”

# insert a blank line above and below every line which matches “regex”

Text Conversion

# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format. assumes all lines end in CR/LF. in bash, press Ctrl-V then Ctrl-M to make ^M

# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format.

# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format.

Other

# remove overstrikes (char, backspace) from man pages. echo may need -e switch if you use a bash shell.

# get Usenet/e-mail message header, delete everything after first blank line

# get Usenet/e-mail message body, delete everything up to first blank line

# get Subject header, but remove initial “Subject: ” portion

# get return address header

# remove most HTML tags (accommodates multiple-line tags)


Posted on August 9th, by admica in programming.
Comments Off

Comments are closed.