title: "Command not found" piping a variable to cut when output stored in a variable
body: <p>In a bash script I am using a variable to hold a path like this:</p>
  
  <pre><code>MY_DIR=/just/a/string/to/my/path
  </code></pre>
  
  <p>And I want to remove the last two parts of it so it looks like this:</p>
  
  <pre><code>/just/a/string
  </code></pre>
  
  <p>I am using 'cut' to do it, like this:</p>
  
  <pre><code>echo $MY_DIR | cut -d'/' -f-4
  </code></pre>
  
  <p>The output is what I expect. Fine.
  But I want to store in an other variable, like this:</p>
  
  <pre><code>MY_DIR2=$($MY_DIR | cut -d'/' -f-4)
  </code></pre>
  
  <p>When I execute the script I get the error:</p>
  
  <pre><code>... /just/a/string/to/my/path: No such file or directory
  </code></pre>
  
  <p>Why is the direct output with echo working, but storing the output in a variable is not?</p>