title: check disk space while copying in shell script
body: <p>I am copying files in parallel using GNU parallel as shown below and it works fine.</p>
  
  <pre><code>export COPY_PRI=/abc/pri
  export COPY_SEC=/pqr/sec
  
  export status_dir=$(mktemp -t -d transfer.XXXXXX)
  cleanup() { rm -rf "$status_dir"; }
  trap cleanup 0
  
  copy() {
    el=$1
    PRIMSEC=$2
    scp bullseye@"$MACHINE_ONE":"$dir3"/process_"$el"_210_5.data "$PRIMSEC"/. || { touch "$status_dir/local_down" &amp;&amp; scp bullseye@"$MACHINE_TWO":"$dir3"/process_"$el"_210_5.data "$PRIMSEC"/.; } || { touch "$status_dir/pri_down" &amp;&amp; scp bullseye@"$MACHINE_THREE":"$dir3"/process_"$el"_210_5.data "$PRIMSEC"/.; } || { touch "$status_dir/sec_down" &amp;&amp; exit 1; }
  }
  export -f copy
  
  parallel -j 3 copy {} $COPY_PRI ::: "${PRI_FILES[@]}" &amp;
  parallel -j 3 copy {} $COPY_SEC ::: "${SEC_FILES[@]}" &amp;
  wait
  </code></pre>
  
  <p>Now I want to check disk space before copying any new files. If disk has 20% space left, then only copy if it doesn't have 20% space left, then exit out of the shell script with an error message and non zero status code. So how can I check disk space after every scp copy and make sure it is not reaching the limits? I have to check <code>/abc</code> and <code>/pqr</code> disk. They are two different disk.</p>