![]() |
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 03: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 05:09 AM |
| pattern matching and print with sed | nymus7 | Shell Programming and Scripting | 2 | 04-14-2005 09:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi Friends,
I am working on a script.. Looking forward for your expert help..... My requirement is: I have a text file where, need to search equip * RTF or end of line with RTF ,once this pattern is found then print 2nd line, 6th line, 7th line to a different file. For Ex: Code:
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 Code:
BCCH 4 0 4 6 9 106 1353 75 NON_BCCH 4 0 4 6 9 106 1351 80 Regards Shalini Last edited by Yogesh Sawant; 06-29-2009 at 04:48 AM.. Reason: added code tags |
|
||||
|
Thanks a lot... It did work after i use the below line
Code:
nawk 'c&&c-- {if (c==5 ||c==1||c==0) printf $0 ((c==0)?ORS:OFS);next} /^*RTF$/ {c=7}' BSC01_CHARKOP.COMBINED > aa1
Code:
BCCH 4 0 4 6 9 106 1351 77 BCCH 4 0 4 6 9 106 1352 68 NON_BCCH 4 0 4 6 9 106 1351 87 NON_BCCH 4 0 4 6 9 106 1351 113 NON_BCCH 4 0 4 6 9 106 1351 122 NON_BCCH 4 0 4 6 9 106 1352 112 NON_BCCH 4 0 4 6 9 106 1352 119 NON_BCCH 4 0 4 6 9 106 1352 124 NON_BCCH 4 0 4 6 9 106 1352 756 Code:
BCCH-4 0 4 6 9 106 1351-77 BCCH-4 0 4 6 9 106 1352-68 NON_BCCH-4 0 4 6 9 106 1351-87-113-122 NON_BCCH-4 0 4 6 9 106 1352-112-119-124 Shalini Last edited by Yogesh Sawant; 06-29-2009 at 04:50 AM.. Reason: added code tags |
|
||||
|
Hi,
Input is same... Now that this output is generated need to just delete the occurances.. Considering same output But output is: Code:
BCCH 4 0 4 6 9 106 1351 77 BCCH 4 0 4 6 9 106 1352 68 NON_BCCH 4 0 4 6 9 106 1351 87 NON_BCCH 4 0 4 6 9 106 1351 113 NON_BCCH 4 0 4 6 9 106 1352 112 NON_BCCH 4 0 4 6 9 106 1351 122 NON_BCCH 4 0 4 6 9 106 1352 119 NON_BCCH 4 0 4 6 9 106 1352 124 NON_BCCH 4 0 4 6 9 106 1352 756 Like Non_BCCH 4 0 4 6 9 106 1351 87 113 122 thats it... Considering the last values in same line... What i tried was: By using below input contents of file.txt: TCS,1 TCS,2 TCS,3 TCS,4 CTS,1 CTS,2 CTS,3 O/P: TCS, 1 2 3 4 CTS, 1 2 3 But i am not sure that al values wil be in continuous manner considering abc,1 abc,2 xyz,5 abc,4 i am not getting Below code awk -F, ' { if(NR == 1) printf("%s",$0); else { if($1 != var) { printf("\n%s,%d",$1,$2); } else printf(" %s",$2); } var = $1; }' file.txt Last edited by Yogesh Sawant; 06-29-2009 at 04:51 AM.. Reason: added code tags |