The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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 09:47 AM
Adding Multiple Lines to Multiple Files dayinthelife Shell Programming and Scripting 2 06-04-2008 12:50 PM
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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-09-2009
jolecanard jolecanard is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 36
Cool Error in multiple files treatment with AWK

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]

Eahc of the "inp.*" file is like that:

Code:
...
m1 xxxx xxxx
     92238 897987
     xxxx xxxx
m2 xxxx xxxx
     92238 123435
     xxxx xxxx
...

The problem is that it returns me both the value in m1 and m2 (I asked only for the values in m2).

Any idea why my script does not return the expected result?

Thanks
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0