title: How to iterate combinations of elements in two arrays in bash?
body: <p>I have 2 different lists, I have separated these in 2 different files.</p>
  <pre><code># cat file1
  
  S1
  S2
  S3
  </code></pre>
  <p>and</p>
  <pre><code># cat file2
  
  R1
  R2
  R3
  </code></pre>
  <p>I want to loop over both files, so in first loop, <code>S1</code> makes all possible cominations with elements in file2, like this</p>
  <pre><code>echo &quot;First List Of Combinations&quot;
  echo S1 + R1
  echo S1 + R2
  echo S1 + R3
  </code></pre>
  <p>then second combinations</p>
  <pre><code>echo &quot;Second List Of Combinations&quot;
  echo S2 + R1
  echo S2 + R2
  echo S2 + R3
  </code></pre>
  <p>So I decided to put these in two arrays.</p>
  <pre><code>arr1 = $(cat file1)
  arr2 = $(cat file2)
  </code></pre>
  <p>what should I read first and what should be incremented? I know this will include 2 while loops reading elements from both arrays.</p>