Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with looping in Bash Shell Script

 
Kishen Singh Punjabi
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am storing the results from DB in an array.

For example ,

Records from DB are as follows:
This is Record One
This is Record Two


when I store the above records in a array and print , it is displayed something as follows:
This is Record One This is Record Two

and when I use for loop for this I get 8 elements with each record split into 4. I understand that this is because for loop takes space as the separator of elements in the array.

I want to store each record from the database as an element in array.

Please help on how do I achieve it. Thanks for the help!!



 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Per this page, quoting allows embedding white space in array elements. There may be other helpful hints on that page if this one is not sufficient.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic