I have this code where the cmd usually works if I sprintf something to it, but when I try to run my Rscript, it does not work. Any hints?
I get the error:
awk: cmd. line:9: cmd = Rscript ./date-script-r.r $1 3 2 1;
awk: cmd. line:9: ^ syntax error
awk: cmd. line:9: cmd = Rscript ./date-script-r.r $1 3 2 1;
awk: cmd. line:9: ^ unterminated regexp
Code:
awk=/usr/bin/awk
awkcommand='
#d is the delimiter
BEGIN { OFS = FS = d }
$1 {
#Expected args for the Rscript: (1, 2, 3, 4) = (dateString, yearPosition, monthPosition, dayPosition)
cmd = Rscript ./date-script-r.r $1 3 2 1;
cmd | getline $1;
print;
close(cmd);
}
awk -v d="," "$awkcommand" output-data/$filename > output-data/tmp.csv
Example of R-script output:
Rscript date-script-r.r 17-12-12 1 2 3
12-12-2017