help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mapfile question: Is there a better way to avoid the trailing newlin


From: Stan Marsh
Subject: Re: mapfile question: Is there a better way to avoid the trailing newline?
Date: Wed, 01 Oct 2025 13:38:46 -0600

>I would bet money you're parsing a Comma-Separated Value (csv) file.

You would lose that bet.  This has nothing to do with csv files.
Try to stay on topic.

>You're probably doing something like this:

>    while IFS= read -r line; do
>        mapfile -t -d $'\t' fields <<< "$line"
>    done

>I strongly recommend against doing this.  It can't handle anything but
>the most trivial csv files -- no quoting, no embedded newlines within
>fields, etc.

Actually, I hate (and avoid) the "while read" pattern even more than
you do.

=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.

When responding to my posts, please try to refrain from giving bureaucratic 
answers.
If you have nothing useful to say, then just click Next and go on.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]