Report Space Remaining on Disk on Unix Login
I get a kick out of stuff like this. Add this to your .bash_profile to be greeted with the remaining space on your disk.
df -h | awk ‘NR==2 {print “Space available " $4}’
This will actually change depending on which version of df you’re using (i think). I get different output on my Mac than I do on a CentOS machine - df seems to auto wrap lines on long drive names, so when I check the space on the CentOS server I need to change the line number (NR goes to 3) and the column to print (down to 3).
On my mac, this is what I get:
haddad:~ jhaddad$ df -h Filesystem Size Used Avail Capacity Mounted on /dev/disk0s2 149Gi 144Gi 4.9Gi 97% / devfs 106Ki 106Ki 0Bi 100% /dev fdesc 1.0Ki 1.0Ki 0Bi 100% /dev map -hosts 0Bi 0Bi 0Bi 100% /net map auto_home 0Bi 0Bi 0Bi 100% /home
haddad:~ jhaddad$ df -h | awk 'NR==2 {print "Space available " $4}' Space available 4.9Gi
I should probably clear some stuff off my drive.