Skip to content

Instantly share code, notes, and snippets.

@caius
Created January 19, 2018 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caius/9c7d23f83f118ccfa85f27474dbbd1fc to your computer and use it in GitHub Desktop.
Save caius/9c7d23f83f118ccfa85f27474dbbd1fc to your computer and use it in GitHub Desktop.
# Pipe `zfs history` into this script, it will output holds
# which have not yet been released.
holds = []
ARGF.each_line do |line|
next unless line[/zfs (hold|release) (\S+) (\S+)/]
kind = $1
tag = $2
snapshot = $3
item = [tag, snapshot]
case kind
when "hold"
holds << item
when "release"
holds.delete(item)
end
end
puts holds.map {|x| x.join("\t") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment