So I'm having an issue with checking the length of a variable in an if statement like so:
Code:
variable="sometext"
if [[ "${#variable}" > 16 ]]; then
echo "Fail"
else
echo "Success"
fi
why doesn't this work? it's smaller so it should resort to else and echo Success but it echo's Fail to the screen. I'm so lost, I've even tried using quotes and taking quotes from areas and it changes nothing as far as I could see. ${#variable} does give you the length of a variables contents...right? If I'm doing this wrong which I do not see how I could be with all the examples I just tested. Thanks in advance
Should I maybe just use awk or expr. Rather not use expr because from what I found out mac doesn't have that built into there OS and I wish to allow for my girlfriend to use this script and she isn't very tech savy and I can't ssh into her machine to install things myself but expr I believe if I remember right a bash function but she is all the way back in bash 3.2 or 3.1
Fixed: I found what I was doing wrong I forgot when using numbers you need (( )) so thats how you fix it :P