detraveller
detraveller

Reputation: 295

Concatenate a string and an integer and assign it to a new column

Code(AWK script):

for(i=0; i<numColumns; ++i){

$(NF+i)="group" #This will print group, but I want to print 
#group1, group2, group3 and so on...
#In other words, i want something like $(NF+i)="group".$i so that 
#the output is group1, group2....

    }

I am adding these words in new columns, hence the (NF+i).

my question is how to concatenate so I can print group1, group2 and so on. I can do that with the print command but I want to assign that to column NF+i.

Upvotes: 0

Views: 127

Answers (1)

Kent
Kent

Reputation: 195289

try: (print statement omitted)

for(i=0; i<numColumns; ++i){

$(NF+i)="group " i


    }

Upvotes: 1

Related Questions