#!/bin/gawk
function convertToCamelCase(text)
{
split(text, words, " "); for (i=1; i<=length(words); i++) { res = res toupper(substr(words[i],1,1))tolower(substr(words[i],2))" ";
return res;
}
function convertToThreeDigitDecimal(num)
{
return sprintf("%7.3f",(num/1000000));
}
BEGIN {
....
I am trying to add a function in awk, it is giving me syntax error.
bash-3.2$ ./execute_all_stats.sh.bak file.csv
awk: get_mkt_stats.awk.bak:7: function convertToThreeDigitDecimal(num)
awk: get_mkt_stats.awk.bak:7: ^ syntax error
awk: get_mkt_stats.awk.bak:11: BEGIN {
awk: get_mkt_stats.awk.bak:11: ^ syntax error
The awk version is:
bash-3.2$ awk --version
GNU Awk 3.1.5
I am calling the awk like the following:
gawk -F',' -f script.awk ${file}