I'm trying to write something so I can handle zfs snapshots for backups of my iocage zpool, but I'm a bit stumped on how zfs prints snapshots. Currently, I have something like this
My intent here is to have no headers and just go one layer in so I'm not getting any sub-datasets. This doesn't seem to create something I can iterate over though, just read. My goal in the end is to have something like this:
According to the man pages, using -H and -p should make this parsable, I can't find anything else that might make this clear in the man pages, how can I make it easier to parse my snapshots in for loops?
Code:
zfs list -Hp -d 1 -t snapshot -o name | grep iocage
My intent here is to have no headers and just go one layer in so I'm not getting any sub-datasets. This doesn't seem to create something I can iterate over though, just read. My goal in the end is to have something like this:
Code:
datasets=$(zfs list -Hp -d 1 -t snapshot -o name | grep iocage)
for i in $datasets; do
do_something
done
According to the man pages, using -H and -p should make this parsable, I can't find anything else that might make this clear in the man pages, how can I make it easier to parse my snapshots in for loops?