title: bash script to parse du -s * output and warn users who are above certain storage limit
body: <p>I am trying to wrote a script to check homefolders disk usage, and warn users when they are above xxGB, by email</p>
  
  <p>I dump the output of the du -s * to a temp file, read it line by line, and when i try to read the size and name of the folder from the output of du it does not work correctly, just doing an echo $file i get each line dumped as two lines, i tried expand to replace the tabs with spaces, but also didn't work, and I am not sure how to do the comaprison based on size too.</p>
  
  <pre><code>#!/bin/bash
  
  #echo "Disk usage report for /homes on `hostname`"
  
  EMAIL="helpdesk@xy.com"
  
  ##########################
  # check staff
  #########################
  
  cd /homes/staff/
  file1="/root/scripts/temp_check"
  file2="/root/scripts/temp_check2"
  du -s * | sort -rn | head -15  |awk '{print}' &gt; $file1
  expand $file1 &gt; $file2
  
  for line in $(cat $file2)
  
  do
  
  echo $line
  
  # echo $line | awk '{ print $2 }'
  
  mail -s "Disk usage report for your homefolder" $EMAIL
  
  done
  </code></pre>