0
Thanks

A few words of thanks would be greatly appreciated.

Sed - inserting spaces


  • 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
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on 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 (https://ccm.net/).

1 Comment