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 8694761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:51:42+00:00 2026-06-13T00:51:42+00:00

is probably a stupid question, but can’t see the reason for while abort. i

  • 0

is probably a stupid question, but can’t see the reason for while abort.

i have a file like this:

"id": "00000000000000000",
"visibilitystate": 1,
"profilestate": 8
"somethingelse": "abc",
"id": "99999999999999999",
"againsomethingelse": "cba"
"visibilitystate": 0,
"profilestate": 9

one million or more repetitions, number,designation and value can be different between id and id, but id is always different.
my first thought was read in a loop, store the value in a array and later insert into mysql-db.

i try this:

set -x
#Data extract array
array=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)

#Control array
array2=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)

while read a; do
    if [[ ${array2[0]} == 1 ]]; then
        awk '/"id":/ { exit 42 }'
        if [[ $? -eq 42 ]]; then
            echo mysql
            array2[0]=0
        fi
    fi
    if [[ ${array2[0]} == 0 ]]; then
        awk '/"id":/ { exit 42 }'
        if [ $? -eq 42 ]; then
            array[0]=`sed -n 's/.*"id":."\(.*\)",.*/\1/p'`
            array2[0]=1
        fi
    fi
done <testf

set +x

after read one line, the loop exit, don’t understand why.

output:

+ array=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
+ array2=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
+ read a
+ [[ 0 == 1 ]]
+ [[ 0 == 0 ]]
+ awk '/"id":/ { exit 42 }'
+ '[' 42 -eq 42 ']'
++ sed -n 's/.*"id":."\(.*\)",.*/\1/p'
+ array[0]=
+ array2[0]=1
+ read a
+ set +x

can someone help me?

  • 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-13T00:51:43+00:00Added an answer on June 13, 2026 at 12:51 am

    There are 3 problems in the script. You are using 3 different commands inside the loop that are reading from stdin (awk twice and sed).

    When you use awk '/"id":/ { exit 42 }' it reads everything else (the input file). You probably want to apply that command in $a. That would be something like:

    echo $a | awk '/"id":/ { exit 42 }'
    

    The second error is the same, but in the next if.

    The third error is similar, but in this case when you use sed. You probably want to do something like:

    array[0]=`echo $a | sed -n 's/.*"id":."\(.*\)",.*/\1/p'`
    

    By the way, test is a reserved word in bash, you should avoid using it as file name (not related with your problem, though).

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

Sidebar

Related Questions

This may sounds like a stupid question but can't find anything on google, probably
Probably a stupid question but so far I can't figure this out... I have
I feel like this is probably a stupid question... but anyway I have this
this is probably a stupid question but I can't seem to find the answer.
I have probably stupid question but how Can I create Many-To-Many relationship with create
I have a simple and probably stupid question, but I can't really find any
This is probably a stupid question, but I can't seem to do it. I
This is probably a stupid question, but I have to ask. I found this
This is a stupid question, but i can't figure it out, say i have
This is probably a really stupid question but I can't figure this out. I

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.