I wrote a script to fill a file for some Disk capacity testing. Could you please tell me why I have an error?
#!/bin/bash
COUNTER=0;
FILE_SIZE_BITS=8589934592;
FILE_NAME="fill_me";
while [ $COUNTER -eq 0 ]; do
echo "Dummy text to fill the file" >> "$FILE_NAME";
SIZE='stat -c%s fill_me';
if [[ $SIZE -gt $FILE_SIZE_BITS ]]; then
let COUNTER=COUNTER+1;
fi
done
the error is:
-bash: [[: stat -c%s fill_me: division by 0 (error token is "fill_me")
Thanks
The error is here:
Do this instead:
This sets SIZE to the output of the
stat -c%s fill_mecommand. The$(...)syntax is theCommand Substitutionsyntax:BTW you can do the same thing with
dd[manual]: