title: while loop to compare files with each other
body: <p>I achived result from for loop as below. Only thing to avoid is to compare same files.</p>
  <pre><code>   $ for (( i = 0; i &lt;= 9; i++ ))      ### Outer for loop ###
  &gt; do
  &gt;
  &gt;     for (( j = 0 ; j &lt;= 9; j++ )) ### Inner for loop ###
  &gt;     do
  &gt;           echo &quot;awk -f cmp.awk SPM_CC&quot;$j&quot;_Log&quot; SPM_CC&quot;$i&quot;_Log&quot; &gt; SPM_CC&quot;$j&quot;_DWN&quot;&quot;&quot;
  &gt;     done
  &gt;
  &gt;
  &gt; done
  awk -f cmp.awk SPM_CC0_Log SPM_CC0_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC0_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC0_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC0_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC0_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC0_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC0_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC0_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC0_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC0_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC1_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC1_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC1_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC1_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC1_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC1_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC1_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC1_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC1_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC1_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC2_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC2_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC2_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC2_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC2_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC2_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC2_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC2_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC2_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC2_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC3_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC3_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC3_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC3_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC3_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC3_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC3_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC3_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC3_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC3_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC4_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC4_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC4_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC4_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC4_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC4_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC4_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC4_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC4_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC4_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC5_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC5_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC5_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC5_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC5_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC5_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC5_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC5_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC5_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC5_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC6_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC6_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC6_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC6_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC6_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC6_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC6_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC6_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC6_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC6_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC7_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC7_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC7_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC7_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC7_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC7_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC7_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC7_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC7_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC7_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC8_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC8_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC8_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC8_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC8_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC8_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC8_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC8_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC8_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC8_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC0_Log SPM_CC9_Log &gt; SPM_CC0_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC9_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC9_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC9_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC9_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC9_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC9_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC9_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC9_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC9_Log &gt; SPM_CC9_DWN
  
  </code></pre>
  <p>I need to fetch various linux command out of loop where Files need to compare with each others. In order to get same need to contruct double while loop.</p>
  <p>For example: SPM_CC1_Log with SPM_CC0_Log to SPM_CC9_Log and vice versa.</p>
  <p>Here is my while loop</p>
  <pre><code>
      n=9
  i=0
  while [ $i -le $n ]
  do
    j=1
    while [ $j -le $n ]
    do
      echo &quot;awk -f cmp.awk SPM_CC&quot;$j&quot;_Log&quot; SPM_CC&quot;$i&quot;_Log&quot; &gt; SPM_CC&quot;$j&quot;_DWN&quot;&quot;&quot;
     i=$((i+1))
     j=$((j+1))
    done
  done
  awk -f cmp.awk SPM_CC1_Log SPM_CC0_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC1_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC3_Log SPM_CC2_Log &gt; SPM_CC3_DWN
  awk -f cmp.awk SPM_CC4_Log SPM_CC3_Log &gt; SPM_CC4_DWN
  awk -f cmp.awk SPM_CC5_Log SPM_CC4_Log &gt; SPM_CC5_DWN
  awk -f cmp.awk SPM_CC6_Log SPM_CC5_Log &gt; SPM_CC6_DWN
  awk -f cmp.awk SPM_CC7_Log SPM_CC6_Log &gt; SPM_CC7_DWN
  awk -f cmp.awk SPM_CC8_Log SPM_CC7_Log &gt; SPM_CC8_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC8_Log &gt; SPM_CC9_DWN
  </code></pre>
  <p>Whereas I need below output from while loop to compare each files with each other.</p>
  <pre><code>
      awk -f cmp.awk SPM_CC1_Log SPM_CC0_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC1_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC2_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC3_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC4_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC5_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC6_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC7_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC8_Log &gt; SPM_CC1_DWN
  awk -f cmp.awk SPM_CC1_Log SPM_CC9_Log &gt; SPM_CC1_DWN
  
  awk -f cmp.awk SPM_CC2_Log SPM_CC0_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC1_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC2_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC3_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC4_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC5_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC6_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC7_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC8_Log &gt; SPM_CC2_DWN
  awk -f cmp.awk SPM_CC2_Log SPM_CC9_Log &gt; SPM_CC2_DWN
  
  ----
  ----
  ----
  ----
  
  awk -f cmp.awk SPM_CC9_Log SPM_CC1_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC2_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC3_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC4_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC5_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC6_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC7_Log &gt; SPM_CC9_DWN
  awk -f cmp.awk SPM_CC9_Log SPM_CC8_Log &gt; SPM_CC9_DWN
  
      
  
  </code></pre>