awk script

Hi,

I'm trying to complete the information in a file, it will be my first AWK script and i have no idea how to do that!
I just get the book sed awk - 2nd edition, By Dale Dougherty & Arnold Robbins to try to understand what I have to do, but if someone can help me in the meanwhile I would be very appreciated!

I have this file:

Line 1-Object Class = common
Line 2-var1,var2,var3,var4,var5,var6,var7,var8,var9,var10,var11,var12,var13,var14,var15,var16,var17,var18,var19,var20,var21,var22,var23,var24,var25
Line 3-123,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
Line 4-,,,,,,,,,,,,,,,,,,,12 00 00 00 00 01 |0,,,,,
Line 5-342,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,, 
�

I need to do the following:
-Where I have lines line number 4 I have to write the previous value that was redden from field var1.

  • I have to start each line with one hardcoded value.
    Output file for this situation:
Line 1-Object Class = common
Line 2-Identifier,var1,var2,var3,var4,var5,var6,var7,var8,var9,var10,var11,var12,var13,var14,var15,var16,var17,var18,var19,var20,var21,var22,var23,var24,var25
Line 3-001,123,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
Line 4-001,123,,,,,,,,,,,,,,,,,,,12 00 00 00 00 01 |0,,,,,
Line 5-001,342,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,, 
�

After doing this I have another thing to do:

  • I must gather this file with others similar (also with var1 on the same position) to this one and order the lines by the field Var1.

Second file after being changed will be like:

Line 1-Object Class = common
Line 2-Identifier,var1,var2,var3,var4,var5,var6,var7,var8,var9,var10,var11,var12,var13,var14,var15,var16,var17,var18,var19,var20,var21,var22,var23,var24,var25
Line 3-002,123,dfd,common,22,1,1,1,false,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
Line 4-002,123,,,,,,,,,,,,,,,,,,,16,,,,,
Line 5-002,342,dfd,common,22,1,1,1,false,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
�

the result that I need is this:

Line 1-Object Class = common
Line 2-var1,var2,var3,var4,var5,var6,var7,var8,var9,var10,var11,var12,var13,var14,var15,var16,var17,var18,var19,var20,var21,var22,var23,var24,var25
Line 3-123,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
Line 4-,,,,,,,,,,,,,,,,,,,12 00 00 00 00 01 |0,,,,,
Line 5-342,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,, 
�

I need to do the following:
-Where I have lines line number 4 i have to write the previous value that was redden from field var1.

  • I have to start each line with one hardcoded value.
    Output file for this situation:
Line 1-Object Class = common
Line 2-Identifier,var1,var2,var3,var4,var5,var6,var7,var8,var9,var10,var11,var12,var13,var14,var15,var16,var17,var18,var19,var20,var21,var22,var23,var24,var25
Line 3-001,123,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
Line 4-001,123,,,,,,,,,,,,,,,,,,,12 00 00 00 00 01 |0,,,,,
Line 5-001,342,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,, 
�

After doing this I have other thing to do:

  • I must gather this file with others similar (also with var1 on the same position) to this one and order the lines by the field � Var1� and after doing this I will also try to order by the field �Identifier�.
    Second file after being changed will be like:
001,123,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
002,123,dfd,common,22,1,1,1,false,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
001,123,,,,,,,,,,,,,,,,,,,12 00 00 00 00 01 |0,,,,,
002,123,,,,,,,,,,,,,,,,,,,16,,,,,
001,342,dfd,common,32434,34,34,23,true,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,, 
002,342,dfd,common,22,1,1,1,false,true,0,0,0|0,0,0,0,0,0,FALSE,23,23,1,,,,
�

-I must discard lines:

Object Class = common
Identifier,var1,var2,var3,var4,var5,var6,var7,var8,var9,var10,var11,var12,var13,var14,var15,var16,var17,var18,var19,var20,var21,var22,var23,var24,var25

If they exist in the beginning of the file;

best regards,
Ricardo Tom�s

It's difficult to make sense of your post... I think you need to edit it and remove some duplicate information?

What have you tried so far.... where are you stuck?