If you are trying to count the total disk space allocated to a server local or remote the following would be useful
ssh user@server df -k | grep -v Filesystem| awk '{print $2}' | paste -sd+ | bc
the output will be total K of your disks.
grep -v Filesystem is to remove your header field for df -k command.
If you are looking for say a particular volume you could grep for it before awk.
For example you want to find the total allocated corresponding to a particular logical volume let say logVol1 you could use the following
ssh user@server df -k | grep logVol1| awk '{print $2}' | paste -sd+ | bc
If you want to do it on local server drop the ssh.
ssh user@server df -k | grep -v Filesystem| awk '{print $2}' | paste -sd+ | bc
the output will be total K of your disks.
grep -v Filesystem is to remove your header field for df -k command.
If you are looking for say a particular volume you could grep for it before awk.
For example you want to find the total allocated corresponding to a particular logical volume let say logVol1 you could use the following
ssh user@server df -k | grep logVol1| awk '{print $2}' | paste -sd+ | bc
If you want to do it on local server drop the ssh.
No comments:
Post a Comment