I have an xml file. I am trying to remove only the blank lines from a range of lines. In this example I want to check lines 55-57 and remove any blank lines.
This needs to be done in a shell script over multiple files that are all xml. This is a RHEL 7 system.
I tried using sed
, but wasn't able to strip the empty lines out.
I have written statements that get the appropriate line numbers, they are stored as vars in the shell script (start_line
, finish_line
)
Example File:
1.
2.
3. <Test></Test>
.
.
.
55.
56.
57.<!-- keep the comment -->
58. <KeepTag></KeepTag>
What can I do to remove the blank lines only from range 55-57?
sed
editor can do this easily :sed -E '55,57{/\S/!d;}'