arrays - Bash How can I use read command to assign multiple words to 1 variable -


I am trying to read many words / logic in one variable. I tried to specify it in an array and using the loop, put all the elements in the array in 1 string.

  read -a info i = 0 datastring = "" while [$ i-lt $ {info [@]}] tautestring = $ datastrings $ {info [i]} "$ dataString" When I run the program, it does nothing and sits there and does not leave printing and I have lost it in some other way.   

itemprop = "text"> <

  reading datastring & lt; & Lt; & Lt; "There are many words in this sentence" echo "$ datastring"   

If you already have an array

  datastring = $ {info [ ]}   

will combine the array into one word, the first letter of $ IFS will be used as a separator. If you want all the words not found in a separator, you can:

  datastring = "" $ {info [@}} "for word; datestring + = $ Word;   

or this:

  datastring = $ (IFS = ""; echo "$ {info [*]}")   

or this:

  datastring = $ {info} * datastring = $ {datastring /}}   

Note, All citations and array indices ( * vs. @ ) have been carefully selected: see and


Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -