![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing the values to the secondary script when it invoked by primary script | venu_eie | UNIX for Advanced & Expert Users | 2 | 07-03-2008 08:10 AM |
| Passing the values to the secondary script when it invoked by primary script | venu_eie | Shell Programming and Scripting | 1 | 07-03-2008 07:16 AM |
| create a shell script that calls another script and and an awk script | magikminox | Shell Programming and Scripting | 0 | 06-26-2008 03:50 AM |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 03:31 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 04:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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: Code:
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: Code:
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: Code:
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: Code:
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: Code:
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: Code:
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: Code:
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 |
![]() |
| Bookmarks |
| Tags |
| awk, script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|