Sed one-liners

Cool! Several handy one-liners for use in Sed, the stream editor.

# double space a file
sed G

# 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.
sed ‘/^$/d;G’

# triple space a file
sed ‘G;G’

# undo double-spacing (assumes even-numbered lines are always blank)
sed ‘n;d’


2 Comments

lu (1 comments.) on May 14, 2004 at 6:23 am.

i’ve been looking for your mail, can you contact me, please?

Reply

Peteris Krumins (1 comments.) on October 8, 2008 at 8:57 am.

Hi.

I wanted to let you know that I wrote an article “Famous Sed One-Liners Explained” which explains all the sed one-liners in that file.

Hope you find it useful! :)

Sincerely,
Peteris Krumins

Reply

Leave Your Comment

Your email will not be published or shared. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Holy Shmoly! is Stephen Fry proof thanks to caching by WP Super Cache