Assigning system command’s output to variable

Note: Coprocess is GNU awk specific.
Anyway another alternative is using getline

cmd = "strip "$1
while ( ( cmd | getline result ) > 0 ) {
  print  result
} 
close(cmd)

Calling close(cmd) will prevent awk to throw this error after a number of calls :

fatal: cannot open pipe `…’ (Too many open files)

Leave a Comment