I have the following line:
[email protected] [The Name], [email protected] [The Name 2], [email protected] [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
[email protected] [email protected] [email protected] ...
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.