This command
echo \"hello world\" | awk \'{split($0, array, \" \")} END{print length(array) }\'
does not work for me and gives this error m
Try this if you are not using gawk.
awk 'BEGIN{test="aaa bbb ccc";a=split(test, ff, " "); print ff[1]; print a; print ff[a]}'
Output:
aaa 3 ccc
8.4.4 Using split() to Create Arrays http://docstore.mik.ua/orelly/unix/sedawk/ch08_04.htm