mirror of
https://github.com/nachoparker/btrfs-du.git
synced 2024-11-23 17:22:54 +01:00
* Add Option to show subvolumes only * Fix spaces in subvolumes not shown Co-authored-by: Jesai Langenbach <j.langenbach@kdz-ws.net>
This commit is contained in:
parent
fdf2d53375
commit
239fbb80da
27
btrfs-du
27
btrfs-du
@ -29,7 +29,26 @@ bytesToHumanIEC() {
|
||||
echo "$b$d${S[$s]}"
|
||||
}
|
||||
|
||||
LOCATION=${1:-/}
|
||||
BTRFS_OPT=""
|
||||
|
||||
while [ ${#} -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-h)
|
||||
echo -en "btrfs-du [-o] <PATH_to_BTRFS-mount>\n\n"
|
||||
echo -en "-o\t\tprint only subvolumes below specified path\n"
|
||||
echo -en "-h\t\tprint help\n"
|
||||
exit 0
|
||||
;;
|
||||
-o)
|
||||
BTRFS_OPT=" -o "
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
LOCATION=${1:-/}
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# checks
|
||||
[[ ${EUID} -ne 0 ]] && {
|
||||
@ -98,9 +117,9 @@ for (( i = 0 ; i < ${#ID__[@]} ; i++ )); do
|
||||
done
|
||||
|
||||
## naming data
|
||||
OUT=$( btrfs subvolume list --sort=rootid "$LOCATION" | cut -d ' ' -f 2,9 )
|
||||
ID__=( $( awk '{ print $1 }' <<< "$OUT" ) )
|
||||
NAM_=( $( awk '{ print $2 }' <<< "$OUT" ) )
|
||||
OUT=$( btrfs subvolume list -t --sort=rootid ${BTRFS_OPT} "$LOCATION"| tail -n +3 )
|
||||
ID__=( $( awk -F "\t" '{ print $1 }' <<< "$OUT" ) )
|
||||
NAM_=( $( awk -F "\t" '{ print $5 }' <<< "$OUT" ) )
|
||||
|
||||
for (( i = 0 ; i < ${#ID__[@]} ; i++ )); do
|
||||
NAME[${ID__[$i]}]=${NAM_[$i]}
|
||||
|
Loading…
Reference in New Issue
Block a user