-1

This question already has an answer here:

Is there an easy way to add four empty lines between each sentence.

For example, this paragraph:

This combination of vitamins and selected minerals is used to prevent or treat vitamin 
deficiency due to poor eating habits, problems that affect the body's ability to absorb nutrition from food, or increased need for vitamins and minerals due to stress 
or illness. Vitamins are needed for the body to function well.
This vitamin/mineral combination contains high levels of B vitamins (e.g., folic acid, 
niacin, B-1, B-2, B-6, and B-12) and vitamin C. It also contains other vitamins (A, D, and E) and minerals such as zinc. This medication does not contain iron and has only a 
small amount of calcium. Therefore, it should not be used to treat "iron-poor" blood 
(anemia) or to prevent osteoporosis.

How I can make it:

This combination of vitamins and selected minerals is used to prevent or treat vitamin 




deficiency due to poor eating habits, problems that affect the body's ability to absorb nutrition from food, or increased need for vitamins and minerals due to stress 




or illness. Vitamins are needed for the body to function well.




This vitamin/mineral combination contains high levels of B vitamins (e.g., folic acid, 




niacin, B-1, B-2, B-6, and B-12) and vitamin C. It also contains other vitamins (A, D, and E) and minerals such as zinc. This medication does not contain iron and has only a 




small amount of calcium. Therefore, it should not be used to treat "iron-poor" blood 




(anemia) or to prevent osteoporosis.

I would like:

1- to add four blank spaces between each line.

2- to add one blank space after the first line then every four spaces

marked as duplicate by αғsнιη, user88036, Romeo Ninov, G-Man, Anthony Geoghegan Oct 14 '18 at 20:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

sed can do it

sed 'G;G;G;G' file

Explanation 💡:

According to sed man the flag G is to append a newline to the contents of the pattern space, and then append the contents of the hold space to that of the pattern space.

In the command above every G would add one new line.

In order to add one blank space after the first line then one empty space every four lines,

In GNU sed:

sed '1~4G' file

1~4 means match every four lines starting with line first,so the above command will begin creating a blank line after the first line and then every four lines.

  • Hi @Goro thank you for the answer and explanation. I have second question, how can I add one empty line every four lines? – Gabi Oct 14 '18 at 12:10
  • @Gabi you are welcome! please update the text of the question, include any additional questions you may have to avoid confusing people. then I will update my answer accordingly! – user88036 Oct 14 '18 at 12:15
0

I have done by below method using sed command

sed "s/.*/&\n\n\n\n/g" filename

Tested and worked fine

Not the answer you're looking for? Browse other questions tagged or ask your own question.