I am writing a script to check for a few things before installing a package. I need to check how much free space the filesystem containing the $PWD has. I wrote and tested the script on RHEL 7.0. I used df -m $PWD|awk {'print $4'}
to get the available free space. This works fine for RHEL 7.0. But in RHEL 6.4 and 7.1, this does not return the free space in MB, but the free % available space on the filesystem. Visually they look the same. I see that the version of the df
command is different from df --version
. This script is to be used across a large variety of RHEL systems. What can be a workaorund to this?
Asked
Active
Viewed 517 times
-2

Adithya Das
- 33
- 4
-
2I believe you already answered or at least partially answered your own question. Both the `df` and `awk` are going to be different versions. Clearly this method of getting free space is unreliable. Maybe try searching for a more general question on SO, such as "bash get free space". Also maybe try some of the solutions [here](http://stackoverflow.com/questions/19703621/get-free-disk-space-with-df-to-just-display-free-space-in-kb) – jkdba Mar 08 '16 at 15:27