This command
echo \"hello world\" | awk \'{split($0, array, \" \")} END{print length(array) }\'
does not work for me and gives this error m
When you split an array, the number of elements is returned, so you can say:
echo "hello world" | awk '{n=split($0, array, " ")} END{print n }' # ------------------------^^^--------------------------------^^
Output is:
2