Skip to content

Instantly share code, notes, and snippets.

@paulmars
Created April 18, 2016 19:13
Show Gist options
  • Save paulmars/285c33e3958aeb00d913c2b088c88ff9 to your computer and use it in GitHub Desktop.
Save paulmars/285c33e3958aeb00d913c2b088c88ff9 to your computer and use it in GitHub Desktop.
delete empty directories
# list directories
dirs = `du -h`.split("\n")
# get empty ones
empty_dirs = dirs.select{|d| d.split("\t").first.strip == "0B" }
# get only names
dir_names = empty_dirs.map{|d| d.split("\t")[1] }
# delete them
dir_names.each {|dir| `rmdir "#{dir}"` }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment