Passing variables into awk from bash -


i writing shell script file in have print columns of file. try use awk. column numbers calculated in script. nprop variable in loop, changes 1 8.

avg=1+3*$nprop awk -v a=$avg '{print $a " " $a+1 " " $a+2}' $filename5 >> neig5.dat 

i have tried following also:

awk -v a=$avg '{print $a " " $(a+1) " " $(a+2) }' $filename5 >> neig5.dat 

this results in printing first 3 columns time.

avg=1+3*$nprop 

this set $avg 1+3*4, literally, if $prop 4 instance. should evaluating expression:

avg=$(( 1+3*$nprop )) 

and use version of awk script parenthesis.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -