Combining multiple lines into one line
awk, scripting, sed, vim
Solution
In vim you could do this with
:g/<abc/ .,/<\/abc/ join!
Normally :join will add a space at the end of each line before joining, but the `!` suppresses that.
In general I would recommend using a proper XML parsing library in a language like Python, Ruby or Perl for manipulating XML files (I recommend Python+ElementTree), but in this case it is simple enough to get away with using a regex solution.
Problem
I have this use case of an xml file with input like ``` Input: <abc a="1"> <val>0.25</val> </abc> <abc a="2"> <val>0.25</val> </abc> <abc a="3"> <val>0.35</val> </abc> ... Output: <abc a="1"><val>0.25</val></abc> <abc a="2"><val>0.25</val></abc> <abc a="3"><val>0.35</val></abc> ``` I have around 200K lines in a file in the Input format, how can I quickly convert this into output format.