Having a slight bit of trouble trying to parse out this one in my head. I'm creating a script in korn shell to find if a file system has at least 5GB. If it does not have 5GB, I want the script to error out.
My code to find the available space is
df -g /u00 | sed -n '2p' | awk '{print $3}'
I am using this in an if statement like
if df -g /u00 | sed -n '2p' | awk '{print $3}' -lt "5.00";
then
#There's less than 5gb
echo "There's less than 5GB, please clear up space to continue"
exit 1
else
echo "Enough space, continuing"
fi
The error I'm getting is
awk: 0602-533 Cannot find or open file -lt.
The source line number is 1.
Enough space, continuing
Obviously, it's not liking where I'm putting -lt in this, and I assume it's the fact that I'm trying to combine it with awk. Problem is, I'm not sure how to write it to where it won't choke next to the awk statement. Is there a better way to do the compare, or am I passing it to -lt incorrectly?
I've also tried passing it as a variable like
export AWK=df -g /u00 | sed -n '2p' | awk '{print $3}'
if [$AWK -lt "5.00"];
then
#There's less than 5gb
echo "There's less than 5GB, please clear up space to continue"
exit 1
else
echo "Enough space, continuing"
fi
And it doesn't seem to like that either