In addition to what Neo has already said, it isn't at all clear what you are really trying to do. Since features vary from system to system and shell to shell, you should always tell us what operating system and shell you're using when starting a thread in the Shell Programming and Scripting forum. You haven't done that.
You haven't shown us what your original input looks like. If you're trying to rewrite your
awk script to produce the output you want instead of the current output you showed us in post #1 in this thread, we need to know details about your input file(s) format(s).
You haven't shown us the
awk script that produces your current output. If you want us to help you fix your code, we have to be able to see your code.
If you want to keep your current
awk script and write another shell,
sed,
awk, or some other utility or combination of utilities; we could do that, but it would be grossly inefficient and would seem to be fighting against your goal of directly producing the final output you want. Whether or not you have tried to write a script to reformat your current output and want to rewrite your script to format your output correctly to start with, we need to see what you have tried to achieve that goal so we have a better understanding of what you do understand and where you're stuck.
So, please help us help you by:
- telling us what operating system you're using,
- telling us what shell you're using,
- showing us the input data (in CODE tags) that was used by your awk script to produce the current output you have shown us and explain to us in English the format of that input data,
- showing us your awk script (in CODE tags) that processed the input data described above and produced the current output you have shown us,
- showing us code that you have tried (in CODE tags) to get the final output you are hoping to produce, and
- explaining to us where you are stuck.