Passing variables into awk from bash

I am writing a shell script file in which I have to print certain columns of a file. So I try to use awk. The column numbers are calculated in the script. Nprop is a variable in a for loop, that changes from 1 to 8.

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

I have tried the following also:

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

This results in printing the first three columns all the time.



This will set $avg to 1+3*4, literally, if $prop is 4 for instance. You should be evaluating that expression:

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

And use the version of the awk script with parenthesis.

Need Your Help

I inserted a jquery slider in magento (flexslider) but it wont load

jquery html slider magento-1.7 zurb-foundation

I'm trying to load a slider called flexslider but its not working and i can't figure it out.

Explicit Intent in Titanium

android titanium android-intent appcelerator-mobile

Is it possible to start an explicit intent from a Titanium Android app? I need to open the evernote new note window with some text passed into it. Is this possible in Titanium?