title: batch script - comparing two arrays
body: <p>I am trying to compare two arrays and if any array element is same then I am printing. I am not getting the proper output. Only one element is displaying (<code>rm.war</code>). See the below batch file and the output.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>@echo off
  setlocal EnableDelayedExpansion
  echo "Application list"
  set all_apps=(jts.war rm.war ccm.war dm.war relm.war qm.war)
  set apps_len=0
  for %%b in %all_apps% do (
      set /A apps_len=apps_len+1
      set apps[!apps_len!]=%%b
      echo %%b
  )
  echo "Installed Applications"
  cd /d D:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin
  set cmd=call wsadmin.bat -lang jython -f C:/temp/tt.py -user wsadmin -password wsadmin
  set insapps_len=0
  for /f %%a in ('%cmd%') do (
    set /A insapps_len=insapps_len+1
    set inslist[!insapps_len!]=%%a
    echo %%a
    )
  echo "Compare arrays"
  for /l %%i in (1,+1,%apps_len%) do (
   for /l %%j in (%insapps_len%,-1,1) do (
      if !apps[%%i]!==!inslist[%%j]!  echo !inslist[%%j]!
   )  
  )
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>"Application list"
  
  jts.war
  rm.war
  ccm.war
  dm.war
  relm.war
  qm.war
  
  "Installed Applications"
  
  WASX7209I:
  DefaultApplication
  admin.war
  ccm.war
  clmhelp.war
  converter.war
  ivtApp
  jts.war
  qm.war
  query
  rm.war
  
  "Compare arrays"
  
   rm.war 
  </code></pre>