I have a txt file with 3 rows, now I want to multiply a variable value with the 2nd column. Given below is my requirement.
cat sample.txt
ABC,123,qwe123
ASD,456,asd123
VBN,6532,wqe123
I have a variable, colum=100. I want to multiply this variable with 2nd column using awk. The code I tried is:
cat sample.txt | awk -F , '{print $1","$2*$($colum)","$3}'
My expected output is:
ABC,12300,qwe123
ASD,45600,asd123
VBN,653200,wqe123
Please note that I want to perform this awk using the variable only, I dont want to directly multiply column 2 with 100.