I do not want to just print value of variables using awk. Actually i want to print value of variables in specific columns of a file. I already tried the link "How to use shell variables in an awk script"
Below is my requirement.
I have two variables and i want to print the values of these variables in specific columns. I have tried below to print the value of variables but it is not giving the desired result.
awk '$2 = $2 FS "$test" infile
From link "How to use shell variables in an awk script" i can understand how to print value of variables by my requirement is to print the values of two variables in specific columns. For example i have two variables and i need to print the value of both variables in column 3 and 4.
Below is the example.
infile
2017/03/31-465 17:00:22 01:20:18 Completed 63249705
2017/03/30-490 17:00:19 00:15:17 Completed 12205725
2017/03/29-502 17:00:19 00:15:12 Completed 12108819
2017/03/28-496 17:00:20 00:14:58 Completed 12060389
2017/03/27-487 17:00:24 00:15:29 Completed 11990615
2017/03/26-76 17:00:22 32:05:10 Completed 62974897
2017/03/24-465 17:00:22 01:24:26 Completed 62974897
2017/03/23-494 17:00:16 00:14:30 Completed 11970151
2017/03/22-489 17:00:19 00:14:49 Completed 11923575
2017/03/21-472 17:00:19 00:14:52 Completed 11878081
2017/03/20-463 17:00:20 02:21:25 Aborted 0
2017/03/12-78 17:00:19 32:05:16 Completed 62466091
I have below 2 variables and i want to print the values of both variables in column say 3 and 4.
variables : - test and test2
I tried using below code . But it print $test
instead of values of variables
test. When i gone through link "How to use shell variables in an awk script" and
able to print the values of variable but not able to print in specific columns
of file.
awk '$3 = $3 FS "$test"' infile