scripting - Why is bash only appending first element to array -


After

I am trying to read a list of files from stdin, with each file delimited from a new line but I see that only the first element is being added to the list. I saw it entering only two stars and then q can anyone explain why?

  files = () ["$ input" while reading the input! = "Q"]; Files + = ("$ input") read inputs for f in $ files; Echo "is the list of files:" echo "$ f" echo #prints 1 "is the length of files" $ {# files} ", even if 2 + are recorded  

Actually your files + = ("$ input") expression is adding element to your array but You are not running it correctly

Your last loop should be:

  for "$ {files [@]}"; Resonant "element is: $ f" done  

test (thanks to @fedorqui)

  $ one + = (1) $ one + = ("Hello") $ A + = (3) in "$ {a [@}}" for $ i; Echo "$ I"; 1 Halo 3  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -