I want to join an array of strings on the string "%2C+". My shell script launch looks like this.
#!/bin/bash
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
selectQuery=$(join_by "%2C+" $1)
echo selectQuery
But when I run ./download-data $("state_code" "county_code"), I get this error in the terminal: bash: state_code: command not found.
I need to pass the argument as an array since I plan to pass more arrays later on. Something like ./download-data $("state_code" "county_code") $("more" "string").
bash;x=(a b)is a special form of the assignment statement.$(...)is a command substitution.eval, but this is ugly. For me, this would be the point where I would think of replacing bash by a programming language which is better suitable for your application.