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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:30:50+00:00 2026-05-24T10:30:50+00:00

Possible Duplicate: Output of command in Bash script to Drop-down box? I have an

  • 0

Possible Duplicate:
Output of command in Bash script to Drop-down box?

I have an array in a bash script. I have apache2 configured so I can run cgi/bash scripts in my cgi-bin directory, and they will display like a webpage.

Is there any way to take each element of the array and make it one result in a drop down box on the page?

For example, if my array looked like:

a[0] = "255" 
a[1] = "254" 
a[2] = "253"
a[3] = "252"
a[4] = "251"

I would want the dropbox to look like (lol, ASCII)

 _____
|255  |
|254  |
|253  |
|252  |
|251  |
 -----

Any suggestions? Thanks for your help.

  • 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-05-24T10:30:51+00:00Added an answer on May 24, 2026 at 10:30 am

    you can write a bash for loop to do everything. This just prints out the elements:

    for i in `seq 1 "${#x[*]}"`; do
        echo "|${x[i]} |"
    done
    

    To get the alignment correct, you need to figure out the max length (one loop) and then print out the terms:

    # w will be the length
    w=0
    for i in `seq 1 "${#x[*]}"`; do
        if [ $w -lt ${#x[$i]} ]; then w=${#x[$i]}; fi
    done
    for i in `seq 1 $((w+2))`; do printf "%s" "-"; done
    printf "\n"
    for i in `seq 1 "${#x[*]}"`; do
        printf "|%-$ws |\n" ${#x[$i]}
    done
    for i in `seq 1 $((w+2))`; do printf "%s" "-"; done
    printf "\n"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Capturing multiple line output to a bash variable I have what is
Possible Duplicate: How can I capture the stdout output of a child process? I'm
Possible Duplicate: DOS command to Display result on console and redirect the output to
Possible Duplicate: PHP - How Detect if Output Buffering is Turned On How can
Possible Duplicate: Python: Date Ordinal Output? In Python time.strftime can produce output like Thursday
Possible Duplicate: run shell command from java I'm trying to run a process with
Possible Duplicate: How do I write a bash script to restart a process if
Possible Duplicate: Can colorized output be captured via shell redirect? setup In this case
Possible Duplicate: Floating point comparison I have some simple C code and the output
Possible Duplicate: Reason for the Output Hi, Can you please explain me the output

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.