Skip to content

Instantly share code, notes, and snippets.

@jacobbednarz
Created April 24, 2012 10:24
Show Gist options
  • Save jacobbednarz/2478627 to your computer and use it in GitHub Desktop.
Save jacobbednarz/2478627 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# Output a prettier version of the number
def prettify_number(number)
formatted_output = number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1 ")
end
# Get the free space of a drive
def get_free_space(path)
bash_listing = `df -h #{path} | grep ^/ | awk '{ print $4;}'`
prettify_number(bash_listing)
end
# Call the mofo
print get_free_space('/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment