With the command of df, I can get something like:Filesystem     1K-blocks     Used Available Use% Mounted on/dev/root      197844228 15578648 180242500   8% /devtmpfs         4101368        0   4101368   0% /devtmpfs             820648      292    820356   1% /runtmpfs               5120        0      5120   0% /run/locktmpfs            1693720        4   1693716   1% /run/shmWhat if I just want to keep the 180242500 number recorded of / and store it in a file (like disk-space-available.txt)If I use df >> disk-space-available.txt it will store all the content while I just want the raw number in that file.For example if there is something like this then it's working:df -OUTPUT=raw-available-number180242500What can I do?
How do I get / available space with df and output it to a log file?
shell
You can filter easily with awk, checking if the last field equal /, then print the corresponding 4th field:df | awk '$NF == / { print $4 }' >> outputor:df / | awk 'NR == 2 { print $4 }' >> output