I have a file -- a, and exist some continues blank line(more than one), see below:
cat a
1
2
3
4
5
So first I want to know if exist continues blank lines, I tried
cat a | grep '
'
nothing output. So I have to use below manner
vi a
:set list
/
So I want to know if exist other shell command could easily implement this? then if exist two and more blank lines I want to convert them to one? see below
1
2
3
4
5
at first I tried below shell
sed 's/
(
)*/
/g' a
it does not work, then I tried this shell
cat a | tr '
' '$' | sed 's/$$($)*/$$/g' | tr '$' '
'
this time it works. And also I want to know if exist other manner could implement this?
See Question&Answers more detail:os