I have a scenario where i want to sum the multiple column
The data in the file is :
ID|NAME|SAL|COST|PER|TAG
1|A|10|10|20|10|
1|B|10|15|20|10|
1|C|10|17|25|80|
1|D|115|110|20|100|
1|E|10|10|10|10|
i want sum of COLUMN - SAL | COST | PER | TAG
one i did with simple command but how to do by creating function
awk '{FS="|"}{s+=$3}END{print s}' file.txt
The function should be parameterised so that when i pass column name it should calculate sum for that column
The sum column's may differ. their may be requirement like only two column sum needed then it should take the two column names and process the sum for that