Looking for an elegant way, when at the end of a
bash script to cleanup the resulting file if:
- the first character of the line below the line to be deleted is
#is the first character of the last line in the file.
File could look like this (line numbers of reference are in
 but are not in the file itself):
 # foo  bar1  bar2  bar3  # foob  #ar  ar1  ar2  ar3  #
In the above example I'd like to delete lines 5 and 10. I do not want any line starting with
# to be followed by a line starting with
# and I do not want the last line of the file to start with
EDIT: Expected output:
 # foo  bar1  bar2  bar3  #ar  ar1  ar2  ar3
bash as I go and am super confused by
awk syntax, but I suspect they are the answer here.