How to get system output in awk?

awk

Solution

You want

op[i] = sprintf("%d\n", SQ substr($1,i,1))

The way to capture output from an external command:

cmd = "date"
cmd | getline output
close(cmd)

http://www.gnu.org/software/gawk/manual/html_node/Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe

Problem

I want to store the printf output to the array like below: ``` op[i] = system( "printf \"%d\\n\" \"" SQ substr($1,i,1) "\"" ) ``` but when I call them back , they just 0 ?! Do you know why!?

Original source

Related problems