File spacing

Double space

$ sed G

Delete all blank lines and double space

$ sed '/^$/d;G'

Triple space a file

$ sed 'G;G'

Undo double-spacing

$ sed 'n;d'

Insert a blank line above line which matches "regex"

$ sed '/regex/{x;p;x;}'

Insert a blank line below line which matches "regex"

$ sed '/regex/G'

Insert a blank line around line which matches "regex"

$ sed '/regex/{x;p;x;G;}'
Comments