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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk question parsing parameter in loop help pls ...

Status
Not open for further replies.

hokky

Technical User
Nov 9, 2006
170
AU
Hi guys,

Here's my code :
Code:
delta_1="one"
delta_2="two"
delta_3="three"

for(i=1;i<4;i++){
     printf "%s \n",delta_i
}

I'm trying to parse one, two three in the print out but it won't work, I've tried "delta"_i as well but it won't work either .. any idea please ?

Thank you
 
Use an array.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
no, inside delta1 already an array, I just give you guys simple example.. any idea?
 
With YOUR posted code:
Code:
delta[1]="one"
delta[2]="two"
delta[3]="three"

for(i=1;i<4;i++){
     printf "%s \n",delta[i]
}

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

Then maybe like this ?
Code:
delta[1,1]="one";   delta[1,2]="two";    delta[1,3]="three"
delta[2,1]="first"; delta[2,2]="second"; delta[2,3]="third"

for (i=1;i<4;i++) {
  printf "%s - %s\n",delta[1,i],delta[2,i]
}

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top