Q:

Assigning a value to a variable in unix

I have a script that accepts an input date in YYYY-MM-DD format.
After that, I used sed to delete the hyphen (-) which gives me an output YYYY MM DD.
My question is, how can I assign those three numbers to a three different variable.
Example:
2013-11-23 will become 2013 11 23
echo "Please input date[yyyy-mm-dd]: "
read date
echo $date | sed 's/\-/ /g' #this will give me the output of yyyy mm dd

I want to assign that three numbers(yyyy, mm, dd) to a variable individually like this;
X=yyyy
Y=mm
Z=dd

Thanks.

A:

Try something like this:
X="2013 11 12"
read X Y Z <<<$(echo $X)

