Skip to content

Instantly share code, notes, and snippets.

@jtagcat
Created June 28, 2022 11:18
Show Gist options
  • Save jtagcat/74e3220552bc70767209447ca9d7397c to your computer and use it in GitHub Desktop.
Save jtagcat/74e3220552bc70767209447ca9d7397c to your computer and use it in GitHub Desktop.
Add excluded size from zfs to ncdu
#!/bin/bash
RDIR="tank/foo"
ncdu_dir=.
dsize_bar="$("$ZFS" list -Hp -o usedds "$RDIR/bar")"
ncdu -0o- "/$RDIR" --exclude=bar \
| sed 's/{"name":"bar","dev":0,"ino":0,"excluded":"pattern"}'\
'/{"name":"bar","dev":0,"ino":0,"excluded":"pattern","dsize":'"$dsize_bar"'}/' \
| gzip > "$ncdu_dir/$(date -uI).ncdu.gz"
@jtagcat
Copy link
Author

jtagcat commented Jun 28, 2022

Yes, I tried JSONpatch, it can't do this. There is no selecŧ, as there is in jq. sed and roll!

Appears like so (foo is lc):
image

ncdu (footer) Total size includes the patched value, apparent size does not (no size parameter). zfs list -o used does not offer the same used as ncdu size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment