title: Two arrays with different length in a loop
body: <p>I have two arrays with different length, and I need to use them in the same loop.</p>
  
  <p>This is the code</p>
  
  <pre><code>#!/bin/bash
  data=`date +%Y-%m-%d`
  data1=`date -d "1 day" +%Y-%m-%d`
  cd /home/test/em_real/
  
  #first array (today and tomorrow) 
  days="$data $data1"
  #second array (00 till 23)
  hours="00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23"
  
  for value in $hours
  do
  
  cp /home/test/em_real/mps_"${days[i++]}"_"$value":00:00 /home/DOMAINS/test_case/
  sleep 10
  done
  </code></pre>
  
  <p>Tt fails, doesn't get days.</p>
  
  <p>How can I do it?</p>
  
  <p>@fedorqui If now, inside the bucle, I want to remove the dash (-) of days and do another order, I don't know why it doesn't get the string , the code is the following: </p>
  
  <pre><code>days=("$data" "$data1")   #create an array properly
  
  for value in {00..23}; do
  for day in "${days[@]}"; do
  cp "/path/mps_${day}_${value}:00:00" /another/path/test_case/
  d=d01
  hourSIMULATION=01
  clean= echo ${day} | sed -e 's/-//g'
  sed -e 's/&lt;domine&gt;/'$d'/g' -e 's/&lt;data-initial&gt;/'$clean$value'/g' -e 's/&lt;hour-SIMULATION&gt;/'$hourSIMULATION'/g' run_prhours &gt; run_pr
  done
  done
  </code></pre>
  
  <p>The string <code>$dayclean</code> is empty when I check inside <code>run_pr</code>, do you know what could be the reason?</p>