Here is a simple function to get free space in kilobytes of a particular path.
# Get free space of provided path in kilobytes. function get_free_space_kb() { local location=$1 local free_space_mb=$(df -k --output=avail ${location} | tail -1 ) echo ${free_space_mb} } # How to call it. get_free_space_kb /tmp