I'm trying to get the disk space available to do some commands afterwards. Unfortunately somehow within the bash-script, I can't write the amount of bytes in a variable to do a while loop when it is checking if there is still some space left to write the data.
#!/bin/bash
set -e
set -u
set -o pipefail
shopt -s nullglob globstar
DISK_ROOTS=("/mnt/nfs1")
for index in "${!DISK_ROOTS[@]}"; do
DISK_ROOT="${DISK_ROOTS[index]}"
available_diskspace= 'df $DISK_ROOT | awk 'NR==2 {print $4}'' ##LINE 34
echo "=== $available_diskspace BYTES Available ==== "
while [ $available_diskspace -gt 5000000 ]
This is the error I get but I'm able to get the size when it is not in the script (?):
x@x:~$ ./v3.sh
./v3.sh: line 34: $4: unbound variable
x@x:~$ df /mnt/nfs1 | awk 'NR==2 {print $4}'
203897600
Any help would be really appreciated!!