bash - check free available space against requered
0
votes
1
answer
100
views
in bash i will run a script that take a look in the folder
folder123/
to know how much space is requered for the files they are in there.
but this requered value will i multiplie with 1,5
and than subtract from the space they are available is at .
if there are enough available space than go on in the script, but if not exit with an error.
for checking how much space is requered i try this
du -b folder123/ | tail -n 1 | awk '{print $1}'
for checking how much space is available, i find out this
df --output=avail -B 1 "$PWD" |tail -n 1
but how to multiplie the requered with 1,5
and than to subtract from the available, in bash-script?
:edit
if i use something like
avail=$(df --output=avail -B 1 . | tail -n 1)
req=$(( $(du -sb tempdir/ | cut -f1) * 3 / 2))
sum=$(printf '%d\n' "$((avail - req))")
but how than to go on to check if $sum are oke?
Asked by user447274
(539 rep)
Oct 10, 2024, 04:31 AM
Last activity: Oct 10, 2024, 07:56 AM
Last activity: Oct 10, 2024, 07:56 AM