title: Check free disk space for current partition in bash
body: <p>I am writing an installer in bash. The user will go to the target directory and runs the install script, so the first action should be to check that there is enough space. I know that df will report all file systems, but I was wondering if there was a way to get the free space just for the partition that the target directory is on.</p>
  
  <p>Edit - the answer I came up with</p>
  
  <pre><code>df $PWD | awk '/[0-9]%/{print $(NF-2)}'
  </code></pre>
  
  <p>Slightly odd because df seems to format its output to fit the terminal, so with a long mount point name the output is shifted down a line</p>