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 Your last loop should be: files + = ("$ input") expression is adding element to your array but You are not running it correctly
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
Post a Comment