Created
April 24, 2012 10:24
-
-
Save jacobbednarz/2478627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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