title: bash is unable to find directories from text file
body: <p><em>super new to bash</em></p>
  <p>I wrote a bash script that works perfectly on one MAC but doesn't on a different MAC.</p>
  <p>The code iteratively cycles through subjects' folders, copies the data, performs some function, deletes the copied data, then moves to the next subject. To do so, I call a text file that contains the subject names, which informs the script to select the corresponding subject folder (using the variable <code>$mri_path</code> in the code below).</p>
  <p>The problem is, on this new MAC- the script can't find the subject's folder using a text file- <strong>error code: file/directory does not exist</strong>. A main difference between MACs is the text file being used- it contains different subject names. I can hardcode the script to find the subjects' folders, so this leads me to suspect the text file is not being read correctly.</p>
  <p>I have tried different text file formats (e.g., unicode, Macintosh formatted, tab delimited)... so I don't know why the script can't find the subject folders.</p>
  <p>Reduced code:</p>
  <pre><code>#!/bin/bash 
  
  #usage: ./dcm2nii_batch.sh subj.txt startline endline
  
  
  s1=$(($2-1))
  s2=$(($3-1))
  
  vars=($(awk -F= '{print$1}' subj.txt));
  
  for ((i=s1; i&lt;s2; i++));
  do mri_path=${vars[$i])};
  
  echo $mri_path;
  echo '***';
  cd /Users/syschaef/Desktop/dcm2nii_batch/Raw/$mri_path
  </code></pre>
  <p>The error occurs at the last line as the <code>cd</code> command fails.</p>
  <hr />
  <p>The text file data are subject identifying numbers that correspond to subject folder names/directories (screenshot):</p>
  <p><a href="https://i.stack.imgur.com/xYRan.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xYRan.png" alt="enter image description here" /></a></p>
  <p>I appreciate you taking the time to read and/or respond!</p>