I need to execute in Bash the following command:
beeline -u "${DATALAKE_NAMENODE_HIVE}:${DATALAKE_NAMENODE_PORT_HIVE}/pcgexp; -hiveconf .... -f ..... "
The thing is that in Linux the ‘;’ character is indicator of end of the command and I also need to use environment variables. How can I do this? How can I achieve this?
Advertisement
Answer
The answer from @ilkkachu is on the money, as is chepner’s comment — quoted semicolons have no special meaning, and quoted arguments make more sense than a quoted SET of arguments.
That said, another handy way of handling arguments in bash is to use arrays.
declare -a b_args=() b_args+=( -u "${DATALAKE_NAMENODE_HIVE}:${DATALAKE_NAMENODE_PORT_HIVE}/pcgexp;" ) b_args+=( -hiveconf "...." ) b_args+=( -f "....." ) beeline "${b_args[@]}"
This helps with manageability — you can comment out a part of the argument list, have a clear view of what’s being set without having a super long command line to figure out.
In a normal (non-associative) array, arguments are always output in the numerical order of their index, which always increments as you append to the array.