I have some data where I want to save some empty lines and delete only empty lines. My data looks like this:
1
2
3
4
5
6
7
8
9
10
I would like the result to be:
1
2
3
4
5
6
7
8
9
10
I tried working with the following commands, but I cannot get it to work:
awk ' /^$/ { print; } /./ { printf("%s ", $0); }'
AND
sed 'N;/^\n$/d;P;D'
In addition, I tried to use cat -s, but this does not necessarily output empty lines. In addition, I played with sed '/^$/', but can not specify only individual lines. Any help is appreciated.
source
share