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

  • Home
  • SEARCH
  • 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 8459615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:22:48+00:00 2026-06-10T13:22:48+00:00

Hello I want to ask a question that is repeated here . I have

  • 0

Hello I want to ask a question that is repeated here.

I have four servers in bash script defined like in the code below.
For each server, I want to maintain the ID of the process I have started on it.
Just for testing, I wanted to initialize each array with 10 20 30 40.
And see if I can access these elements as expected. However I cannot access the elements.
Could someone tell me what exactly I am doing wrong.

#!/bin/bash
SERVER_LIST=("server1" "server2" "server3")

for server in ${SERVER_LIST[@]} ; do
    echo $server
    arrayName=$server"process"
    echo $arrayName
    set -a "$arrayName=(10 20 30 40)"
done

current_sever=${SERVER_LIST[0]}
arrayName=$current_server"process"
# The attempt below is failing.
eval "echo Server ${current_server} \${$arrayName[*]}"
echo $(eval echo \${arrayName[*]})Server server1

server1process

It gives me output as follows –

Server server1

server1process

Can someone help please.
Also can you please tell me how to append new element to the array?
I tried the following, but it doesn’t work –

sleep 10 &
arrayName=$current_server"process"
eval "\${$arrayName[*]}+=$!"
  • 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-10T13:22:49+00:00Added an answer on June 10, 2026 at 1:22 pm

    Try replacing line 8:

    set -a "$arrayName=(10 20 30 40)"
    

    with:

    eval "$arrayName=(10 20 30 40)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello every one I want to ask a question that what is simple exec
Hello guys, just want you to ask something about my code... I have 5
hello every one I want to ask a question about forking here is the
hello every one i want to ask that i have read that we can
I have an NSString like @Hello World and want to convert that into an
Hello i want to ask how can i optimize that code: $('#infoTrigger0').live('click', function() {
Hello all I am working in javascript and html5.I want to ask that how
Hello every one I want to ask a question about file transfer using sockets.
Hello ever one I want to ask a question about file opening.I want to
Hello everyone I want to ask a question about including guards in C programming.

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.