Skip to main content

Timeline for Bash array with spaces in elements

Current License: CC BY-SA 3.0

10 events
when toggle format what by license comment
Feb 6 at 2:16 comment added user1751825 This was the only solution that worked for me. However, as others have mentioned, IFS needs to be set before array assignment.
Aug 16, 2023 at 22:50 comment added Code Commander What is this Satanic black magic?! (Apparently it is this)
Oct 24, 2018 at 5:36 comment added pkamb Great, only answer on this page that worked. But I also had to move the IFS="" before the array construction.
Oct 21, 2017 at 19:42 comment added csonuryilmaz It also worked for me on bash. Thanks @Khushneet I was searching it for half an hour...
May 26, 2017 at 18:05 comment added arntg Paulo, see another answer here which may be better for your case: stackoverflow.com/a/9089186/1041319. Have not tried IFS="", and seems it does solve it elegantly - but your example shows why one may encounter issues in some cases. It may be possible to set the IFS="" on a single line, but it may still be more confusing than the other solution.
Oct 9, 2015 at 14:37 comment added Paulo Pedroso I am using several arrays to parse info and I shall have the effect of IFS="" working in only one of them. Once I use IFS="" all other arrays stop parsing accordingly. Any hints about this?
Apr 2, 2015 at 7:52 comment added rob I had to move the IFS="" to before the array assignment but this is the correct answer.
S Sep 24, 2012 at 14:26 review Late answers
Sep 24, 2012 at 16:40
S Sep 24, 2012 at 14:26 review First posts
Sep 25, 2012 at 13:07
Sep 24, 2012 at 14:23 history answered Khushneet CC BY-SA 3.0