1

I'm trying to create a a variable using two variables with a whitespace between them. I want to use this new variable to create a folder. The problem is that with the whitespace, it gets interpeted as a speration of the variable and creates two folder, one with the first var and another with the second! Is there any way to make bash consider that it is as whitespace?

my_array=($(echo $dataString | tr ":" "\n"))
for i in "${my_array[@]}"
do
    echo $i
done
echo

year=${my_array[2]}
month=${my_array[3]}
day=${my_array[4]}
hour=${my_array[5]}
min=${my_array[6]}`

year_month="$year $month"

if [ -d "$year_month" ]; then
    echo "$year_month exists"
else 
    mkdir $year_month
    echo "$year_month created"
fi
nonick66
  • 11
  • 1

0 Answers0