On Tue, Jan 24, 2023 at 10:28:32AM -0500, Greg Wooledge wrote:
> Normally, I'd suggest you use mapfile when you've got multiple lines
> of input, and each line can be arbitrarily long or complex. Use IFS/read
> when you've got a single line, and you're trying to "split" it into
> an array of fields (like the over-simplistic way people try to parse a
> CSV file, which is doomed to failure in any real-life case).
>
> By the way, when using IFS/read for parsing "CSV-like" input, beware of
> the "empty fields at the end" pitfall.
>https://mywiki.wooledge.org/BashPitfalls#pf47
Right, and also of fields with field-separator inside... I use
perl/python/sqlite for parsing CSV files.
> If you can show us a (worst case!) sample of your actual input, we can
> suggest parsing approaches that would be suitable to that input.
Thanks. I don't have such example (I'm not the OP) -- I was just wondering
why mapfile was used...
Sincerely,
--
Leonid Isaev