Is it possible to parse the output of xfs_quota -c "free" /mnt/xfs
in a deterministic way? The problem is that depending on the length of the path to the block device mounted on /mnt/xfs
its output will be differently formatted.
With a block device with sufficiently short block device path xfs_quota
will output on a single line:
└$ xfs_quota -c "free" /mnt/xfs
Filesystem 1K-blocks Used Available Use% Pathname
/dev/loop20 983040 289076 693964 29% /mnt/xfs
But if the block device has a long path, for example if it is part of a LVM volume, the output will be split over multiple lines:
$ xfs_quota -c "free" /scratch/local
Filesystem 1K-blocks Used Available Use% Pathname
/dev/mapper/vg_scratch-lv_scratch
1230848 32996 1197852 3% /scratch/local
Xfs_quota
has a flag -N
to hide headers, presumably to ease machine readability; but using it does not remove this variable behaviour.
$ xfs_quota -c "free -N" /scratch/local
/dev/mapper/vg_scratch-lv_scratch
1230848 32996 1197852 3% /scratch/local