You can execute a command and read the result with 'getline' using the syntax :
Code:
command | getline [variable]
The following awk script read commands, execute them and print result.
Code:
awk '
function ExecCmde(cmde ,line, result) {
while ((cmde | getline line) > 0) {
result = result (result=="" ? "" : "\n") line ;
}
return result;
}
tolower($1) ~ /exit|quit/ {
exit;
}
NF>0 {
print "===",$0,"===";
print ExecCmde($0);
print "===";
}
'