bash indirect reference by reference
A lot of similar questions, but hadn't found one for using a variable in
the name this way:
#!/bin/bash
# $1 should be 'dev' or 'stg'
dev_path="/path/to/dev"
stg_path="/path/to/stg"
# Use $1 as input to determine which path to 'execute' to execute
${!\$1'_path'}/bin/execute
Using $1, I want to be able to reference either $dev_path or $stg_path ($1
== 'dev' or $1 == 'stg')
I've tried various iterations of using ! and \$ in various places from
other posts, but no luck
No comments:
Post a Comment