I would like to get the remaining disk space in my home directory:
df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 20G 15G 3.5G 81% /
/dev/root 20G 15G 3.5G 81% /
devtmpfs 990M 4.0K 990M 1% /dev
none 199M 2.7M 196M 2% /run
none 5.0M 0 5.0M 0% /run/lock
none 991M 12K 991M 1% /run/shm
/dev/sda2 894G 847G 1.9G 100% /home
Note: All I need from the output above is 1.9G
use grep
to take only the /home line, and awk
to get only the field you want:
df -h | grep -w /home | awk '{print $4}'