ok thanks that worked..
here is what i want to do next. i have this file called test which has values as follows:
Code:
1
2
3
4
5
6
7
i have another file called data with multiple fields and records as follows:
(there are more columns but following is just a snapshot of the file)
Code:
col1 col2
1 1.4
2 1.6
3 1.7
4 1.8
5 1.9
6 2.0
i would like to get a file with entries as follows: (i am subtracting each row from the data file for the first column from the first entry of the first row in the test file)
Code:
col1 col2
1-1 1.4-2
2-1 1.6-2
3-1 1.7-2
4-1 1.8-2
5-1 1.9-2
6-1 2.0-2
so far i was trying something along these lines:
Code:
awk 'NR==FNR{for(i=1;i<=NF;i++) {a[NR]=$i;next} {b[NR]=$i;next} END {for(i=1;i<=NF;i++) {printf("%1.11f, %1.11f\n",a[i],b[i])}}' test data > try
i am trying to save all the rows from the test file in an array(a). how do i save the col1 and col2 values from the data file in an array and then use it to subtract values from array(a)? i want to stick to awk.
thanks
|