Ok so spaces separate elements. What if you wanted an element to have a space in it?
For instance:
nums="one two three and a half"
where "three and a half" is THE SAME element?
Ok so spaces separate elements. What if you wanted an element to have a space in it?
For instance:
nums="one two three and a half"
where "three and a half" is THE SAME element?
Try using single quote around the element or escape the space.
Yes. Single quote the elements to make it as a single entity and also you need to evaluate it..
#!/bin/ksh
nums="one two 'three and a half'"
eval set -A NM $(echo $nums)
echo ${NM[0]}
echo ${NM[1]}
echo ${NM[2]}
Output:
one
two
three and a half
Or you can do it directly in ksh/bash:
NUMS=(one two "three and a half")
echo ${NUMS[0]}
echo ${NUMS[1]}
echo ${NUMS[2]}