AWK and multiple lines from shell command
Posted by Ktoso on 15/11/2009 – 16:11
Let’s say you want to read the ps output inside an AWK script, it’s not so simple since system returns an exit code and not the string you want – it’s being sent to stdout, here is a simple trick to read multiple lines from a shell command inside awk:
awk 'BEGIN{while ("ps aux" | getline){ print "test " $1 " test"}}' /dev/null | more


Post a reply