So I am starting to learn bash scripting and here is my issue, I have to compare 2 strings and figure out if one of them is greater than a certain number and if so, if one of the strings contains the elements of the other string. One of my 2 variables is evolving at each iteration. That’s pretty straight forward and I thought that I came up with a good solution but it seems like the 2 conditions are never met and nothing gets displayed on the screen, although I know that it’s supposed to work.
Here is my code :
#!/bin/bash
var="8dm7KsjU28B7v621Jls"
value="ERmFRMVZ0U2paTlJYTkxDZz09Cg"
for i in {1..40}
do
var=$(echo -n "$var" | base64)
if [ ${#var} -gt 113450 ]; then
if [ "$var" = "$value" ]; then
echo -e "conditions réunies"
echo -e "${var: -20}"
break
fi
fi
done
Semih Turkoglu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.