title: Use `pbcopy` as path for cd command
body: <p>I am using Automator on my Mac to set up a service that passes a selected folder to a bash shell script as arguments.
  In the script I do:</p>
  
  <pre><code>for f in "$@"; do
      printf "%q\n" "$f" | pbcopy
  done
  </code></pre>
  
  <p>if I then do:</p>
  
  <pre><code>echo `pbpaste`
  </code></pre>
  
  <p>I get the path to my selected folder with spaces escaped (<code>\</code>). I then wanted to use this path to <code>cd</code> into that directory and do a bunch of other stuff (creating a blank directory structure). I hoped I could just do:</p>
  
  <pre><code>cd `pbpaste`
  </code></pre>
  
  <p>but this doesn't work.
  If I type the path manually the <code>cd</code> works so I assume the is some issue with data types or returns or something??</p>
  
  <p>I'll admit I don't really know what this script actually doing and may be going about this all wrong but but if anyone can explain what's going on here and how to get it working it that would be great but even better would be a pointer to a really good resource for a complete beginner to start learning about shell scripting.
  I really like the idea of getting into this a bit more but all the resources I have found are either total basics (cd, ls, pwd etc) or really high level and assume a bunch of previous knowledge.
  What I'd really like is a full language reference with some actual examples like you find for the languages I am more used to (HTML/CSS/JS/AS3), if such a thing exists.</p>
  
  <p>Cheers for any help :)</p>