Skip to content

Instantly share code, notes, and snippets.

@umito
Last active November 21, 2021 09:53
Show Gist options
  • Select an option

  • Save umito/9198097 to your computer and use it in GitHub Desktop.

Select an option

Save umito/9198097 to your computer and use it in GitHub Desktop.
#!/bin/bash
CUR_PATH=`pwd`
ZFS_CHECK_OUTPUT=$(zfs get type $CUR_PATH 2>&1 > /dev/null) > /dev/null
if [[ $ZFS_CHECK_OUTPUT == *not\ a\ ZFS* ]]
then
IS_ZFS=false
else
IS_ZFS=true
fi
if [[ $IS_ZFS = false ]]
then
df $CUR_PATH | tail -1 | awk '{print $2" "$4}'
else
USED=$((`zfs get -o value -Hp used $CUR_PATH` / 1024)) > /dev/null
AVAIL=$((`zfs get -o value -Hp available $CUR_PATH` / 1024)) > /dev/null
TOTAL=$(($USED+$AVAIL)) > /dev/null
echo $TOTAL $AVAIL
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment