I’m trying to untar a file. Before untarring I would like to know free space available on the mounted volume. The plan is if there is not enough space I will not untar it! So how can I find the free space available on a mounted volume using Perl? By the way, I’m using Perl for tar and untar.
Everybody is saying about df and dh but these commands doesn’t work on the mount points. What if I want to find the free space that I can write into on a mounted point?
Using shell commands to generate a single K-free number which Perl can use:
Change into the directory where you want to untar (if not already there) and execute:
Or replace ‘.’ with the actual mount point.
The grep gets rid of the header and the awk prints out the kilobytes available for both split and no-split lines.
This is based on the following sort of output, you may have to adjust if your UNIX outputs something different: