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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -