Get free disk space under unix with df command : Utilities « File Directory « Ruby






Get free disk space under unix with df command


def freespace(device=".")
  lines = %x(df -k #{device}).split("\n")
  n = lines.last.split[1].to_i * 1024
end

puts freespace("/tmp")    

 








Related examples in the same category

1.delete a folder recursively
2.Find files
3.Delete with condition
4.Get free disk space under windows with dir command
5.Call system function to delete a folder
6.Showing Line Numbers
7.Delete folder older than a certain time
8.Parse line: value|value
9.Change a | delimited file