![]() |
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 |
| Combine multiple columns from multiple files | martva | Shell Programming and Scripting | 5 | 12-02-2008 09:23 AM |
| replace multiple lines in multiple files | unihp1 | Shell Programming and Scripting | 1 | 09-21-2008 08:47 AM |
| Adding Multiple Lines to Multiple Files | dayinthelife | Shell Programming and Scripting | 2 | 06-04-2008 11:50 AM |
| Unix log treatment | farzolito | Shell Programming and Scripting | 2 | 03-03-2004 05:41 AM |
| Searching multiple files with multiple expressions | Anahka | Shell Programming and Scripting | 6 | 01-07-2004 06:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hello,
My code is like that: Code:
awk -v f=92238 '$1~/^m2/{tok1=1;next}tok1==1&&$0~f{tok1=0;print $NF}' inp.[1-9] inp.1[0-5]
Code:
...
m1 xxxx xxxx
92238 897987
xxxx xxxx
m2 xxxx xxxx
92238 123435
xxxx xxxx
...
Any idea why my script does not return the expected result? Thanks |
|
||||
|
Finally I found!! Just posting the message helped me figuring out the solution:
In the end of the first read file, it found an occurence of ^m2 (m201), and then when it closes the first file and opens the second one, it keeps looking for "92238", and it finds it in the block "m1". To solve this problem, just need to use ^m2$ instead of ^m2 . ![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|