I'm running a script in Bash on a Mac and I am trying to split a string with the delimiter being a space into an array. The command I'm running is:
array = ($(echo "$string" | tr ' ' "\n"))
that returns the "unexpected '('" error. I've tried multiple solutions including
- escaping the parentheses
- putting quotes around the command
- making sure the space wasn't causing the error
- making sure my header is
#!/bin/bash