Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The problem is to read variables with read command dynamically from a read command in bash without knowing how many they are in advance and store them into an array .

I tested with :

read -p "array : " array[{0..#}]    

as

read -p "array : " array[{0..3}]

works

But with no success .

share|improve this question
up vote 1 down vote accepted

From the read usage output you can actually use the -a flag.

read -p "array: " -a array
share|improve this answer
    
you're right , how i miss that !!! ^^ – Begoul Nov 18 at 21:00
    
@Begoul I just updated my answer check again. – Zachary Brady Nov 18 at 21:00
    
got it , thank you !!! – Begoul Nov 18 at 21:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.