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 ]]
echo $var | tail -c 20
echo -e “Conditions have not been met”
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