I have a string: Gatto piu bello anche cane in file. I am using awk to split it and to put it into array. But the output is not in the right order.
My code is:
Although there is an accepted answer that's not the idiomatic. awk already parses the record to fields and the fields can be accessed with $1 to $NF.
You can then iterate over the fields to do whatever you want.
{ for(i=1;i<=NF;i++)
do_something_with $i
}
Perhaps you have a more complex requirement but not clear from the description.