I'm trying to implement shell script to read csv file and do the sum of 2 columns and adding into new column called total. But it's not successfully done. please suggest how can I achieve this.
my input csv file
a,b,c
1,2,3
4,5,6
expected output
a,b,c,total
1,2,3,5
4,5,6,11
Here a is a primary key
I tried below code to achieve this
echo "First arg: 1"
awk "{print $3 $2 """""" $1}"
echo "First arg: 2
awk -F, "{$(NF+1)=Null;}1" OFS=, file.csv
awk -F "," "{print $1,$2,$3,$2+$3}"
my output is:
C:\Users\inrenan\NIFI\NIFI-1~1.2-B\NIFI-1~1.2>awk -F "," "{print $1,$2,$3,$2+$3}"
a b c 0
1 2 3 5
4 5 6 11
only I'm facing the issue is column name