If this is the same array you asked for help populating recently, you could remove those quotes where it's being populated rather than in a separate stage afterwards. The awk script I'm using there is specifically adding double quotes to it's output because that's what you show you wanted in your question - obviously it doesn't need to do that and it could trivially remove the remaining quotes.
Here's one way to enhance the answer to your previous question to not populate the fields[]
array with surrounding quotes:
$ cat tst.sh
#!/usr/bin/env bash
while IFS= read -d '' -r record; do
readarray -d $'\n' -t fields <<< "$record"
printf '%s\n' "${fields[@]}"
done < <( awk -v ORS='\0' '{gsub(/","/,"\n"); gsub(/^"|"$/,"")} 1' "${@:--}" )
$ ./tst.sh file
AC XA, S.A.
City of Commerce
00
0A348E541E6F5C258A12A5674AEF25F28BA7DCFAECEECC4EE63B71B361606AC3
Included
Included
Included
Not Included
09/30/2003
09/30/2037
SZ=City of Commerce; FE=http://website.org; O=AC XA SA CIF A39201827; C=QR
--BINARY BLOB--maXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEiMCAGA1UEAxMZQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdDAeFw0wMzA5MzAUIC0gMjAxNjESMBAGA1UEBRMJQTgyNzQzMjg3MRgwFgYDVQRhDA9WQVRFUy1BODI3NDMyODcxGzAZBgNVBAoMEkFDIENBTUVSRklSTUEgUy5BLjEnMCUGA1UEAwweR0xPQkFMIENIQU1CRVJTSUdOIFJPT1QgLSAyMDE2MB4XDTE2MDQxNDA3NTAwNloXDTQwMDQwODA3NTAwNlowggEIMQswCQYDVQQGEwJFUzEPMA0GA1UECAwGTUFEUklEMQ8wDQYDVQQHDAZNQURSSUQxOjA4BgNVBAsMMXNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MxJzAlBgNVBAsMHkdMT0JBTCBDSEFNQkVSU0lHTiBST09UIC0gMjAxNjESMBAGA1UEBRMJQTgyNzQzMjg3MRgwFgYDVQRhDA9WQVRFUy1BODI3NDMyODcxGzAZBgNVBAoMEkFDIENBTUVSRklSTUEgUy5BLjEnMCUGA1UEAwweR0xPQkFMIENIQU1CRVJTSUdOIFJPT1QgLSAyMDE2MIICIjANBgkqhkiG9w0BAQEF--END--
SZ1qSRW
Email
AFX Client;Email
AFX Method;AFX Method;Entry Point;AFX Email;Time Stamping
No Entry
We're adding readarray
now as we can't populate fields[]
directly while reading in this case since an empty field would result in back-to-back \n
s and when IFS
is set to a white-space character such as \n
, read
uses contiguous appearances of that character as a single separator and so empty fields would be skipped.