bashを使用したxfs_quota -c 'free'出力の解析

bashを使用したxfs_quota -c 'free'出力の解析

xfs_quota -c "free" /mnt/xfs出力を決定的に解析できますか?問題は、出力に搭載されたブロックデバイスのパス長によって/mnt/xfsフォーマットが異なることです。

ブロックデバイスパスが十分に短いブロックデバイスの場合、xfs_quotaこれは1行に出力されます。

└$ xfs_quota -c "free" /mnt/xfs
Filesystem           1K-blocks       Used  Available  Use% Pathname
/dev/loop20             983040     289076     693964   29% /mnt/xfs

ただし、ブロックデバイスのパスが長い場合(たとえば、LVMボリュームの一部である場合)、出力は複数行に分割されます。

$ 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-Nおそらく、マシンの読みやすさを簡単にするためにヘッダーを隠すフラグがありますが、それを使用してもこの変数の動作は削除されません。

$ xfs_quota -c "free -N" /scratch/local
/dev/mapper/vg_scratch-lv_scratch
                       1230848      32996    1197852    3% /scratch/local

ベストアンサー1

おすすめ記事