KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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. avg=1+3*$nprop 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.
Tags (comma-separated)
Save Edits
Cancel