What am I doing wrong in this for-loop? I have the variable $gGID which contain some numbers. I have another that uses the top number of the list which is the $ONEGID variable. I want to use $ONEGID be matched against the list in $gGID and if a match do something else continue.
echo $ONEGID
116899029375914044550
I collect whats in $gGID with
gGID=$(curl -A 'Mozilla/4.0' --silent "https://www.google.com/search?q=$Daniel%20Sandman%20plus.google.com" | grep -P -o '(?<=plus.google.com/)[^az/u]+(?=/)')
This is what $gGID gives me..
echo $gGID
116899029375914044550
116899029375914044550
116899029375914044550
108176814619778619437
108176814619778619437
108176814619778619437
105237212888595777019
105237212888595777019
105237212888595777019
This is the for-loop I use to match it.
for USERS in $gGID; do
if [ "$USERS" = "$ONEGID" ]; then
echo "More than one match"
else
echo "Just one match"
fi
done
I have tried in multiple ways and not figured it out. I don’t see what I am doing wrong. Could it be that the variable I stored in $gGID count as a single number and that is why?
Not certain what you mean, why would you echo “just one match” when it does not match? Anyway, is this what you mean?
(Tested before the question was changed to include curl – works with the curl as well)