Sed - inserting spaces

July 2017


  • Insert a blank line after each sentence (punctuated by a carriage return)
    • sed G file.txt
  • Insert a blank line after each sentence (punctuated by a carriage return), without taking into account the existing white lines:
    • sed '/^$/d;G' file.txt
  • Add two blank lines after each sentence (punctuated by a carriage return)
    • sed 'G;G' file.txt
  • Insert a blank line before each line "matched" by / pattern /"(" pattern "can be a regular expression)
    • sed '/End/{x;p;x}' file.txt
  • Insert a blank line after each line "matched" by / pattern /"(" pattern "can be a regular expression)
    • s
      ed '/Start/G' file.txt
  • Insert a blank line before and after each line "matched" by / pattern /"(" pattern "can be a regular expression)
    • sed '/Stream Editor/{x;p;x;G}' file.txt

Related


Published by jak58. Latest update on May 18, 2011 at 02:07 PM by jak58.
This document, titled "Sed - inserting spaces," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).