![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| I want to print next 3 lines after pattern matching. | naree | Shell Programming and Scripting | 12 | 05-21-2009 04:04 AM |
| counting the lines matching a pattern, in between two pattern, and generate a tab | d.chauliac | Shell Programming and Scripting | 4 | 03-19-2009 01:30 PM |
| Perl script to match a pattern and print lines | ammu | Shell Programming and Scripting | 6 | 12-22-2008 04:26 AM |
| Print block of lines matching a pattern | vanand420 | Shell Programming and Scripting | 1 | 09-29-2008 06:09 AM |
| pattern matching and print with sed | nymus7 | Shell Programming and Scripting | 2 | 04-14-2005 10:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Actually input is first thing what i have posted-----
equip 1 RTF FULL BCCH 2 0 0 4 0 4 6 9 106 1353 75 255 255 255 255 255 255 255 255 5 5 5 5 5 5 5 5 0 2 0 0 3 3 0 equip 2 RTF FULL NON_BCCH 0 1 0 4 0 4 6 9 106 1351 80 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 2 1 0 1 0 equip 2 RTF FULL NON_BCCH 0 1 0 4 0 4 6 9 106 1352 80 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 2 1 0 1 0 equip 2 RTF FULL NON_BCCH 0 1 0 4 0 4 6 9 106 1351 89 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 2 1 0 1 0 So i have just split my requiremnts instead of directly getting used below line as suggested by you : Code:
nawk 'c&&c-- {if (c==1||c==0) printf $0 ((c==0)?ORS:OFS);next} /^*RTF$/ {c=6}' myFile
Code:
4 0 4 6 9 106 1353 75 4 0 4 6 9 106 1351 80 4 0 4 6 9 106 1352 80 4 0 4 6 9 106 1351 89 Code:
4 0 4 6 9 106 1353 75 4 0 4 6 9 106 1351 80 89 4 0 4 6 9 106 1352 80 ![]() Last edited by Yogesh Sawant; 06-29-2009 at 06:07 AM.. Reason: added code tags |
|
||||
|
Quote:
So, can we conclude that you have got this from your original input Quote:
Quote:
|
|
||||
|
@Rakesh
No actually... Code:as quoted by you 4 0 4 6 9 106 1353 75 4 0 4 6 9 106 1351 80 89 4 0 4 6 9 106 1352 80 Is already met to get thm in this format using the below code -------------------------------------- nawk ' c&&c-- { if (c==1||c==0) { if (c!=0) idx=(idx)?idx OFS $0:$0 else a[idx]=(idx in a)?a[idx] OFS $0:$0 } next } /^*RTF$/ {c=7;idx=""} END { for (i in a) print i OFS a[i] }' inputfile --------------------------------------- And consider this input as below: Inputfile: add_cell 4 0 4 6 9 106 1311 2 frequency_type = 1 bsic = 2Ah wait_indication_parameters = 10 ccch_conf = 0 add_cell 4 0 4 6 9 106 1312 2 frequency_type = 1 bsic = 3Ah wait_indication_parameters = 10 ccch_conf = 0 equip 1 RTF FULL BCCH 0 0 0 4 0 4 6 9 106 1311 69 255 255 255 255 255 255 255 255 equip 1 RTF FULL BCCH 1 0 0 4 0 4 6 9 106 1312 77 255 255 255 255 255 255 255 255 equip 1 RTF FULL NON_BCCH 0 2 0 4 0 4 6 9 106 1311 82 0 0 0 0 0 0 0 0 chg_hop_params cell_number = 4 0 4 6 9 106 1311 0 1 1 80 82 119 45 chg_hop_params cell_number = 4 0 4 6 9 106 1311 1 1 1 869 873 38 So if you see above code wil provide output as below: 4 0 4 6 9 106 1311 69 82 4 0 4 6 9 106 1312 77 But my requirement is : 4 0 4 6 9 106 1311 2AH 69 82 45 38 4 0 4 6 9 106 1312 3AH 77 Hope u got it , Let me know if any queries |
|
||||
|
Hey this is coool.. Thanks a lot
....---------- Post updated at 07:07 PM ---------- Previous update was at 06:21 PM ---------- @vgersh99 ------------------------------------------ nawk ' c&&c-- { if (c==1||c==0) { if (c!=0) idx=(idx)?idx OFS $0:$0 else a[idx]=(idx in a)?a[idx] OFS $0:$0 } next } /^*RTF$/ {c=7;idx=""} END { for (i in a) print i OFS a[i] }' inputfile ------------------------------------------------------------------------- Hey The above piece of code is working perfectly fine when want to retrieve on basis of one pattern i.e RTF condering the below input as same before, can you help me with in cases of two or three patterns for example : Inputfile: add_cell 4 0 4 6 9 106 1311 2 frequency_type = 1 bsic = 2Ah wait_indication_parameters = 10 ccch_conf = 0 add_cell 4 0 4 6 9 106 1312 2 frequency_type = 1 bsic = 3Ah wait_indication_parameters = 10 ccch_conf = 0 equip 1 RTF FULL BCCH 0 0 0 4 0 4 6 9 106 1311 69 255 255 255 255 255 255 255 255 equip 1 RTF FULL BCCH 1 0 0 4 0 4 6 9 106 1312 77 255 255 255 255 255 255 255 255 equip 1 RTF FULL NON_BCCH 0 2 0 4 0 4 6 9 106 1311 82 0 0 0 0 0 0 0 0 chg_hop_params cell_number = 4 0 4 6 9 106 1351 0 1 1 80 82 119 45 chg_hop_params cell_number = 4 0 4 6 9 106 1351 1 1 1 869 873 38 Considering this input, Output can we get it as below: 4 0 4 6 9 106 1311 2Ah 69 82 45 38 4 0 4 6 9 106 1312 3Ah 77 )))......... The first group of numbers is from Key: *RTF ,2nd Key is BSIC, 3rd Key is same *RTF...Is this possible...????? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|