Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8042601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:38:25+00:00 2026-06-05T04:38:25+00:00

What am I doing wrong in this for-loop? I have the variable $gGID which

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:38:26+00:00Added an answer on June 5, 2026 at 4:38 am

    Not certain what you mean, why would you echo “just one match” when it does not match? Anyway, is this what you mean?

    #!/bin/bash
    
    ONEGID=116899029375914044550  
    
    gGID=\
    "116899029375914044550 
    116899029375914044550 
    116899029375914044550 
    108176814619778619437 
    108176814619778619437 
    108176814619778619437 
    105237212888595777019 
    105237212888595777019 
    105237212888595777019"
    
    matches=0
    
    for USERS in $gGID; do 
        if [[ $USERS == $ONEGID ]]
        then 
            (( matches++ ))
        fi 
    done 
    
    if (( matches == 0 ))
    then
        echo "no matches"
    elif ((matches == 1 ))
    then
        echo "Just one match"
    else
        echo "$matches matches"
        echo "more than one match"
    fi
    

    (Tested before the question was changed to include curl – works with the curl as well)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this loop written in C++, that compiled with MSVC2010 takes a long
This is for a Terrain Generation and rendering program. I have a loop that
What am I doing wrong with this helper for my HAML template? def display_event(event)
What am I doing wrong with this: $sql = SELECT * FROM content WHERE
What am I doing wrong in this HTML code: <html> <head> </head> <body> <div
I dont know what am doing wrong with this piece of Code. Its making
Can anyone please point out what im doing wrong with this Stored Procedure please.
Hi can someone tell me what i'm doing wrong in this jquery statement. I
I can't figure out what I'm doing wrong in this template. Here's my data:
What am I doing wrong to get this error? replacements = {} replacements[**] =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.