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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:56:21+00:00 2026-06-11T12:56:21+00:00

this question is not the same as Does the shell support sets? i know

  • 0

this question is not the same as Does the shell support sets?

i know lots of script language support list structure, such as python, python, ruby, and javascript, so what about linux shell?

does shell support such syntax?

for i in list:
do
     print i
done

i would first to initialize a list, for example:

ListName = [ item1, item2, ..., itemn ]

then iterate over it

is that possible when programming shell scripts?

  • 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-11T12:56:22+00:00Added an answer on June 11, 2026 at 12:56 pm

    It supports lists, but not as a separate data structure (ignoring arrays for the moment).

    The for loop iterates over a list (in the generic sense) of white-space separated values, regardless of how that list is created, whether literally:

    for i in 1 2 3; do
        echo "$i"
    done
    

    or via parameter expansion:

    listVar="1 2 3"
    for i in $listVar; do
        echo "$i"
    done
    

    or command substitution:

    for i in $(echo 1; echo 2; echo 3); do
        echo "$i"
    done
    

    An array is just a special parameter which can contain a more structured list of value, where each element can itself contain whitespace. Compare the difference:

    array=("item 1" "item 2" "item 3")
    for i in "${array[@]}"; do   # The quotes are necessary here
        echo "$i"
    done
    
    list='"item 1" "item 2" "item 3"'
    for i in $list; do
        echo $i
    done
    for i in "$list"; do
        echo $i
    done
    for i in ${array[@]}; do
        echo $i
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is not language-aware. I wanna know how can I recognize a returning
This question is related to (but perhaps not quite the same as): Does Django
Note: This is similar to this question but it is not the same. I
I am having the same issues as per this question: WCF not deserializing JSON
This question might not seem very technical but, out of curiosity,I want to know
(This question does not rely on a specific IoC framework, so the interfaces and
[This question is related to but not the same as this one .] My
This question is not technical, but is still about programming. What is the funniest,
This question is not about caching. I need this in-memory table for many small
This question is not about which is the best, it is about which makes

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.