RosettaCodeData/Task/Execute-a-system-command/AWK/execute-a-system-command-2.awk

16 lines
379 B
Awk
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
BEGIN {
ls = sys2var("ls")
print ls
}
function sys2var(command ,fish, scale, ship) {
command = command " 2>/dev/null"
while ( (command | getline fish) > 0 ) {
if ( ++scale == 1 )
ship = fish
else
ship = ship "\n" fish
}
close(command)
return ship
}