User Tools

Site Tools


linux:bash_check_filesize
#!/bin/bash
 
filename="some-file-name"
filesize=$(stat --printf="%s\n" $filename)
minimum="100000000"
expected=$(( minimum / 1000000 ))
if [ "$filesize" -le "$minimum" ]; then
printf "File $filename is smaller than $expected"mb." aborting...\n\n"
rm $filename ; exit
else printf "File $filename is greater than $expected"mb." continuing...\n\n"
fi
linux/bash_check_filesize.txt · Last modified: 10/02/2024 20:30 by Allan