FG
💻 Software

how to get elements from list in bash?

Fresh5 days ago
Mar 15, 2026180237 views
Confidence Score1%
1%

Problem

Here is a LIST: How to get the second element "1234" without looping all the list?

Error Output

List = "abcd 1234 jvm something"

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: how to get elements from list in bash?

Low Risk

Just to supplement ghostdog's answer: you could also put 's elements into an array and access the specific list element from there Note that the array indices are counted 0,1,2,... . This has the advantage of not polluting the shell environment with too many new variables.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment