shell - Passing value from a file to awk script -


i trying pass columns file awk script , 1 it.the input text file "prac.txt" contains:

shashank 12 ram 13 shyam 44 

the awk script "aweg" contains:

#!/bin/awk -f { i=$2 print "val: ",$i+1; } 

the command firing is:

more prac.txt |./aweg 

i getting below output:

val:  1 val:  1 val:  1 

please point out mistakes.

the awk variables not called dollar sign. hence, use:

print "val: ",i+1;               ^               no $ 

all together, yields:

$ awk -f aweg.awk prac.txt    # note no need `more prac.txt`... val:  13 val:  14 val:  45 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -