Intro to Bash Scripting | Comparison Operators Question

Hey all,

Spent about an hour trying to fix my script that I wrote for this question to no avail Question is ‘Create an “If-Else” condition in the “For”-Loop that checks if the variable named “var” contains the contents of the variable named “value”. Additionally, the variable “var” must contain more than 113,450 characters. If these conditions are met, the script must then print the last 20 characters of the variable “var”.’

The statement I wrote is:

if [[ “$var” == “$value” && “$var” -gt 113450 ]]
then
echo $var | tail -c 20
exit 0
else
echo -e “Conditions have not been met”
exit 1
fi
done

I’m getting conditions haven’t met, so the syntax of the string comparison I’m writing seems to be correct (since it’s reaching the else statement without error) but isn’t returning the desired results. I feel like it may have something to do with the string operator I’m using? (==).

Any help would be appreciated since I’m legitimately awful at scripting. Thanks

You ask if $var = ERmFRMVZ0U2paTlJYTkxDZz09Cg and if $var is greater than 113450.
This can only return false.

You would have to ask if the number of characters in $var is greater than 113450 and if so if $var contains the string $value.

This might help you with the string matching part of your comparison: regex - Pattern matching in if statement in bash - Stack Overflow
-onthesauce