input - How to read a value on a specific line in an external file into an AWK script -
input file:
2 5 7 1 2
modifier file (external file):
4 6 2 7 9
what want achieve is, summarizing line1 input file line1 external file.
awk script:
sum=$1+[value of line 1 on modifier file]; printf("%s\n", sum);
expected output:
6 11 9 8 11
$ awk 'nr==fnr{m[nr]=$0;next} {print $0+m[fnr]}' modifierfile inputfile 6 11 9 8 11
Comments
Post a Comment