2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 636
/ 3 Years ago, thu, august 19, 2021, 6:07:03
Currently I'm trying to check file size from reading a directory
read directory
dirsize=$(du -sh $directory)
if [[ "$dirsize" -ge 2MB ]]; then
echo 'High'
elif [[ "$dirsize" -le 2MB ]]; then
echo 'Low'
fi
The problem is when I check file size, the output will be like
4.0K ./......./...
32M ./......./...
So, when I write my code it doesn't work and I don't know how to fix.
For example,
if [[ "$dirsize" -ge 2MB ]]; then
echo 'High'
From code above, my point is to echo 'High' if file is greater than 2MB.
Could you give advice please.
More From » command-line