Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

from gawk to nawk 1

Status
Not open for further replies.

tini1208

Technical User
Feb 13, 2006
56
DE
dear all,

i've got a code, written in awk. it also worked in gawk, but now i only have the nawk available and it doesn't work anylonger.

so...here is the code:

Code:
awk '(x-$1)*((x>$1)+(-1*(x<$1)))>2{++f}\{print>"outfile"f;x=$1}' infile

this code searches for differences in the first column, which are larger than 2 and splits the file into pieces by this.
what changes? i hope anybody can help me!!

thanks a lot!!!
 
Code:
nawk '(x-$1)*((x>$1)-(x<$1))>2{++f}{print>("outfile"f);x=$1}' infile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
dear all,

i am using the code above and i am wondering, why the code abords after the creation of 60 files. is there a maxiumum number of files, which can be created during one cycle?

regards, tini
 
Code:
nawk '(x-$1)*((x>$1)-(x<$1))>2{[!]if(f)close("outfile"f);[/!]++f}{print>("outfile"f);x=$1}' infile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV...you are great!!!
thanks for the very fast answer!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top