You're viewing a comment by vignesh and its responses.

vignesh Permalink
March 06, 2015, 17:36

can anyone help me To add a blank line after a short line ending with . ( insert a blnk line at the end of paragraph)

Comment Responses

FernandoBasso Permalink
March 07, 2015, 12:42

@vignesh,

This is one possible solution for your question:

sed $'s/\.$/\\n/' < nl.txt

It uses a special shell quoting mechanism to insert a newline. It should work on Bash, Zsh, Ksh, and possibly other shells.

Join #Sed on freenode.

vignesh Permalink
March 07, 2015, 14:20

@FernandoBasso
thank u .... but that command is matchin a . at every end of line... can i need to add a new blank line only after the end of paragraph... can u please modify the command

Anirudh Permalink
February 03, 2016, 10:48
sed -ne '
   # store the paragraph in hold space
   H; $bend; /^[.]$/!d

   :end
      # append a newline at the paragraph"s end & print it
      g; s/^\n//; s/\(\n\)[.]$/&\1/p;
      # null hold in preparation for storing the next para
      s/.*//; h
'

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "computer_95": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.