Created
January 19, 2018 23:39
-
-
Save caius/9c7d23f83f118ccfa85f27474dbbd1fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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