Check free disk space for current partition in bash
Yes:
df -k .
for the current directory.
df -k /some/dir
if you want to check a specific directory.
You might also want to check out the stat(1)
command if your system has it. You can specify output formats to make it easier for your script to parse. Here's a little example:
$ echo $(($(stat -f --format="%a*%S" .)))
-
df
command : Report file system disk space usage -
du
command : Estimate file space usage
Type df -h
or df -k
to list free disk space:
$ df -h
OR
$ df -k
du
shows how much space one or more files or directories is using:
$ du -sh
The -s
option summarizes the space a directory is using and -h
option provides Human-readable output.