EN
Bash - print free disk space
10
points
In this short article, we would like to show how to print currently free and used space under Linux/Unix using Bash.
Quick solution (run the following command):
df -h
Where -h causes printing in human-readable format (KB, MB, GB).
Example output:
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 40M 356M 11% /run
/dev/sda1 50G 48G 0 100% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs 395M 0 395M 0% /run/user/1001
Summary:
- at first, we need to find mounting point that keeps data
(in our case all tings are stored in the same place:/),- we can see the device
/dev/sda1mounted as/has capacity50GB, is used48GB, is available0MB.