mardi 5 mai 2015

Shell script to delete a line next to empty lines

I'm able to delete empty lines from a file using grep or sed. But, I'm unable to resolve a scenario where I have to delete a valid line next to an empty line. Following is an example:

Source:

1_1
1_2
1_3
1
2_1
2_2
2_3
2_4
2_5
2

3
4_1
4_2
4
5_1
5_2
5_3
5_4
5



6
7_1
7
8_1
8_2
8

Output:

1_1
1_2
1_3
1
2_1
2_2
2_3
2_4
2_5
2
4_1
4_2
4
5_1
5_2
5_3
5_4
5
7_1
7
8_1
8_2
8

How to delete the valid line next to empty lines?

Aucun commentaire:

Enregistrer un commentaire