You can delete a ZFS filesystem (or other dataset) with
zfs destroy <dataset>. That fails if the dataset has children, including snapshots.
zfs destroy -r <dataset> will remove the filesystem and its children, but will also destroy any non-snapshot children of the filesystem. Is there a succinct way to say "Delete this filesystem and its snapshots, but only if it has no non-snapshot children"?
Basically, I have a number of nested filesystems and I'm using snapshots extensively, both for replication and for cheap backups. I would like a way to easily remove child filesystems and their snapshots (e.g.
zfs destroy tank/container/leaf) while providing a modicum of protection against accidentally nuking the entire filesystem collection (e.g.
zfs destroy tank/container<enter>leaf)
In case it matters, I'm using ZFS on Linux with Scientific Linux 7.
Based on longneck's comment, I can do this with two lines:
zfs destroy tank/example/leaf@% zfs destroy tank/example/leaf
I've tested it and it does exactly what I want.