I have the following line:
name@mail.addr [The Name], name2@mail2.addr2 [The Name 2], name3@mail.addr3 [Name 3], ...
and so on, all on one line ($ROW
). (It's osascript
output based on the user's multi-choice selection from a list.)
Later on in the script I want to run a loop only over the email addresses:
for ADDRESS in $ROW ; do
which by default would use a whitespace as delimiter.
So I need to delete everything between every " [" (incl. the space before) and the following "]," … so that the result is
name@mail.addr name2@mail2.addr2 name3@mail.addr3 ...
until the end of the line (the variable).
The problem is that I'm doing this on macOS which has the BSD versions of sed, awk etc., and until now I could only find GNU solutions. I do have the coreutils installed, so I could do it with GNU, but this a script meant for macOS distribution to other Mac users, who might not have installed coreutils, so GNU sed, awk etc. are not an option.