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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:33:52+00:00 2026-06-07T08:33:52+00:00

I am writing a program and trying to break up data, which is stored

  • 0

I am writing a program and trying to break up data, which is stored in an array, in order to make it run faster.
I am attempting to go about it this way:

    data_to_analyze=(1 2 3 4 5 6 7 8 9 10)
    #original array size
    dataSize=(${#data_to_analyze[@]})

    #half of that size
    let samSmall="$dataSize/2"

    #the other half
    let samSmall2=("$dataSize - $samSmall -1")

    #the first half
    smallArray=("${data_to_analyze[@]:0:$samSmall}")

    #the rest
    smallArray2=("${data_to_analyze[@]:$samSmall:$samSmall2}")

    #an array of names(which correspond to arrays)
    combArray=(smallArray smallArray2)
    sizeComb=(${#combArray[@]})

    #for the length of the new array
    for ((i=0; i<= $sizeComb ; i++)); do
        #through first set of data and then loop back around for the second arrays data? 
        for sample_name in ${combArray[i]}; do
            command
            wait
            command
            wait
        done

What I imagine this does is gives only the first array of data to the for loop at first. When the first array is done it should go through again with the second array set.

That leaves me with two questions. Is combArray really passing the two smaller arrays? And is there a better way?

  • 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-07T08:33:56+00:00Added an answer on June 7, 2026 at 8:33 am
    #!/bin/bash
    data_to_analyze=(1 2 3 4 5 6 7 8 9 10)
    dataSize=${#data_to_analyze[@]}
    ((samSmall=dataSize/2,samSmall2=dataSize-samSmall))
    smallArray=("${data_to_analyze[@]:0:$samSmall}")
    smallArray2=("${data_to_analyze[@]:$samSmall:$samSmall2}")
    combArray=(smallArray smallArray2)
    sizeComb=${#combArray[@]}
    for ((i=0;i<$sizeComb;i++));do
        eval 'a=("${'${combArray[i]}'[@]}")'
        for sample_name in "${a[@]}";do
            ...
        done 
    done
    

    EDIT: removed the double quotes near ${combArray[i]} and replaced <= by < in for

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

Sidebar

Related Questions

I am writing a simple program, which is trying to find next palindrome number
I am currently trying to make a Writing program. I would like the functionality
I am writing a program that needs to run a java.jar server. I need
I'm writing a program that needs a generic temp folder. I'm trying to find
I'm writing a program trying to implement a toy XML processor. Right now the
I am writing a program for class in which I analyze different product codes
I am trying to use the python library mosquitto for writing a program for
I am writing a program which will type a line of text in 5
I'm writing a program using PyQt and I'm trying to figure out a way
I am writing a program in C. I am trying to learn the difference

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.