title: How to get first two directories of path
body: <p>I have a path in linux bash script in a variable. This path could be</p>
  
  <pre><code>/a/b/c/d/t.json
  /a/b/c/d/e/f/t.json
  /a/b/t.json
  </code></pre>
  
  <p>I want to get the first 2 directories. The output should be <code>/a/b</code> for all 3 example paths above.</p>