The Bash function below will return the number of kilobytes of free space of the provided path. function GET_FREE_SPACE_KB() { local LOCATION=$1 local FREE_SPACE_MB=$(df -k --output=avail ${LOCATION} | tail -1 ) echo ${FREE_SPACE_MB} } Bash About the author Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.