I had to fiddle a bit with this so possibly worth keeping a note of it.
I wanted to pull all the node hostnames and ip addresses from chef for use in hostname lookups and ssh config.
knife exec -E 'nodes.find("*:*") {|n| printf "%s - %s \n", n["hostname"] , n["ipaddress"] }'