title: Shell Script check if file exists, and has read permissions
body: <p>In my shell script i'm trying to check if a specific file is exists and if it has reading permissions.</p>
  
  <p>My file's path has spaces in it.</p>
  
  <p><strong>I quoted the file path:</strong></p>
  
  <pre><code>file='/my/path/with\ some\ \spaces/file.txt'
  </code></pre>
  
  <p><strong>This is the function to check if the file exists:</strong></p>
  
  <pre><code>#Check if file exists and is readable
  checkIfFileExists() {
      #Check if file exists
      if ! [ -e $1 ]; then
          error "$1 does not exists";
      fi
  
      #Check if file permissions allow reading
      if ! [ -r $1 ]; then
          error "$1 does not allow reading, please set the file permissions";
      fi
  }
  </code></pre>
  
  <p><strong>Here I double quote to make sure it gets the file as a one argument:</strong></p>
  
  <pre><code>checkIfFileExists "'$file'";
  </code></pre>
  
  <p><strong>And I receive an error from the bash saying:</strong></p>
  
  <pre><code>[: too many arguments
  </code></pre>
  
  <p>Which make me thinks it doesn't get it as a one argument.</p>
  
  <p>But in my custom error, I do get the whole path, and it says it doesn't exists. </p>
  
  <pre><code>Error: '/my/path/with\ some\ \spaces/file.txt' does not exists
  </code></pre>
  
  <p>Although it does exists, and when I tried to read it with "cat $file" I get a permission error..</p>
  
  <p>what am I'm doing wrong?</p>