title: Bash String Comparison with Spaces
body: <p>Alright all, I'm new to bash and having some issues comparing a string to another in a for loop.</p>
  
  <pre><code>   #loop through usb repo main folder to gather file names.  Then check in that folder to find out if 'repodata' exists.  If it does then do a createrepo -update if not then run a regular createrepo to make the file
  
  RepoPath="/media/My Passport/RHEL_Repo/rhel-6-workstation-all"
  
  for j in "$RepoPath"/*
    do
      if [[ "$j" != "$RepoPath/repodata" ]]
        then
          for repoDir in "$j"/*
            do
  
  #I would like this to evaluate if the directory ends with a folder named "repodata"...it is currently incomplete
              if [[ -d "$repoDir"]] 
                then
                  echo "$repoDir"
                  echo folder exists
                  #createrepo -v -update /media/My Passport/RHEL_Repo/rhel-6-workstation-all/$j
              else
                  echo "$repoDir"
                  echo does not exist
                  #createrepo -v /media/My Passport/RHEL_Repo/rhel-6-workstation-all/$j
              fi
          done
      else
        echo Incorrect Eval
      fi
  done
  </code></pre>
  
  <p>The issue is that the variable string "RepoPath" has a space in it.  This causes the loop to separate the first half into the first var and the second into another is evert path.  The inner nested "if" then evaluates to the "else" and prints each piece and echo "does not exist".  </p>
  
  <p>I'm stumped on this and was wondering if anyone could help me fix the issue which seems to be caused by the space in the path variable.  Thanks.</p>