3 ms·
Would you mind expanding with a couple of examples? (E.g. using "foo bar" as a single line or split by whitespace). I suspect I'll really like your way of doin
by patrickdavey 5y ago
Would you mind expanding with a couple of examples? (E.g. using "foo bar" as a single line or split by whitespace).
I suspect I'll really like your way of doing things, but an example would be very handy.
- yudlejoza 5y agoThe example of "foo bar" didn't work with while but inserting tr fixes it: echo "foo bar" | tr ' ' '\n' | while read -r var; do echo ${var}; done For examples in general, I guess something like "cat file.csv" could work. (the difference between using IFS= and not using it is essentially whether we want to preserve leading and trailing whitespaces or not. If we want to preserve, then we should use IFS=).