Bash script that takes in an integer in mb and loops through machine containing directory with size

So I am a bash script that takes in an integer then I will loop through the machine’s home directories. I will then need to output or echo out the users whose hoem directory takes up more space than what I input. What I have written so far can be seen below:

#!/bin/bash
#shell script - How to loop over users? - Unix & Linux Stack Exchange

size=$($1 * 1000000)
getent passwd | while IFS=: read -r name password uid gid gecos home shell; do
i=$(du -sh $home | awk ‘{$1}’)
if [ $i -ge size]
then
echo $name
fi
done

So I am trying to awk the first number(size of home directory) when I du -sh my inputs. However what I got was the 4th line was not found: size=$($1 * 1000000), which is the conversion of my input into mb to do a proper comparison. Subsequently as the 4th line is not found: if [ $i -ge size] this also output a line not found as well since it cannot be evaluated as I cannot fix line 4. Hence how do I fix the size to use it for comparison with my awk. Thank you

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.