Hi!
I did bash script to both exercises (Conditionals and Comparison) but ain’t getting the right results. May anyone help me finding the right answer?
[Conditional Exercise]
#!/bin/bash
var=“nef892na9s1p9asn2aJs71nIsm”
for counter in {1…40}
do
var=$(echo $var | base64)
((counter += 1))
if [ $counter -le 35 ]
then
echo $var | wc -c
fi
done
[Comparison Exercise]
#!/bin/bash
var=“8dm7KsjU28B7v621Jls”
value=“ERmFRMVZ0U2paTlJYTkxDZz09Cg”
for i in {1…40}
do
var=$(echo “$var” | base64)
((i+=1))
if [[ “$var” == “$value” ]] && (( ${#var} > 113450 ))
then
echo “The last 20 characters of var are: ${var: -20}.”
else
echo “Variables does not meet both conditions.”
fi
done
Thanks